Fix include! implementation for Rust file
Also add tests for including Rust file
This commit is contained in:
parent
d302f30144
commit
d7a2ff8008
|
@ -0,0 +1 @@
|
|||
59
|
|
@ -0,0 +1 @@
|
|||
<% let a = include!("includes/rust.rs"); %><%= a %>
|
|
@ -0,0 +1 @@
|
|||
value + 1
|
|
@ -184,6 +184,17 @@ fn test_rust_macro() {
|
|||
assert_render("rust_macro", RustMacro { value: Some(10) });
|
||||
}
|
||||
|
||||
#[derive(TemplateOnce)]
|
||||
#[template(path = "include_rust.stpl")]
|
||||
struct IncludeRust {
|
||||
value: usize,
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_include_rust() {
|
||||
assert_render("include_rust", IncludeRust { value: 58 });
|
||||
}
|
||||
|
||||
#[cfg(unix)]
|
||||
mod unix {
|
||||
use super::*;
|
||||
|
|
|
@ -63,7 +63,7 @@ impl<'s, 'h> VisitMut for ResolverImpl<'s, 'h> {
|
|||
let absolute_path =
|
||||
self.path_stack.last().unwrap().parent().unwrap().join(arg);
|
||||
let absolute_path_str = absolute_path.to_string_lossy();
|
||||
em.mac.tokens = quote! { include!(#absolute_path_str) };
|
||||
*i = syn::parse2(quote! { include!(#absolute_path_str) }).unwrap();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue