Skip to content

Commit f6e58b3

Browse files
jyn514syphar
authored andcommitted
Fix syntax error when rendering topbar for source page
Apparently `'krate' in __tera_context` checks for the string 'krate' in the *serialized context*, not the field `krate`. This is utterly horrifying and I refuse to be convinced otherwise.
1 parent 9ca7e4c commit f6e58b3

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

src/web/source.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,4 +305,18 @@ mod tests {
305305
Ok(())
306306
})
307307
}
308+
#[test]
309+
fn literal_krate_description() {
310+
wrapper(|env| {
311+
env.fake_release()
312+
.name("rustc-ap-syntax")
313+
.version("178.0.0")
314+
.description("some stuff with krate")
315+
.source_file("fold.rs", b"fn foo() {}")
316+
.create()?;
317+
let web = env.frontend();
318+
assert_success("/crate/rustc-ap-syntax/178.0.0/source/fold.rs", web)?;
319+
Ok(())
320+
})
321+
}
308322
}

templates/rustdoc/topbar.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
{%- include "header/topbar_begin.html" -%}{#
77
extra whitespace unremovable, need to use html tags unaffacted by whitespace T_T
88
#}<ul class="pure-menu-list">
9-
{%- if 'krate' in __tera_context -%}
9+
{%- if krate -%}
1010
<li class="pure-menu-item pure-menu-has-children">
1111
<a href="#" class="pure-menu-link crate-name" title="{{ krate.description }}">
1212
{{ "cube" | fas }}

0 commit comments

Comments
 (0)