aboutsummaryrefslogtreecommitdiffstats
path: root/askama_derive/src/generator.rs
diff options
context:
space:
mode:
authorLibravatar Dirkjan Ochtman <dirkjan@ochtman.nl>2017-08-06 14:59:19 +0200
committerLibravatar Dirkjan Ochtman <dirkjan@ochtman.nl>2017-08-06 14:59:27 +0200
commit47df34c0f000429511fda7982e3ef1b4cd2d4569 (patch)
tree327d5348e63cedec415b726a850db45ccce67f94 /askama_derive/src/generator.rs
parent077c56c00782ff826e46258f678ef0f163f4e3cb (diff)
downloadaskama-47df34c0f000429511fda7982e3ef1b4cd2d4569.tar.gz
askama-47df34c0f000429511fda7982e3ef1b4cd2d4569.tar.bz2
askama-47df34c0f000429511fda7982e3ef1b4cd2d4569.zip
Expand include node to template source during code generation
Diffstat (limited to '')
-rw-r--r--askama_derive/src/generator.rs8
1 files changed, 5 insertions, 3 deletions
diff --git a/askama_derive/src/generator.rs b/askama_derive/src/generator.rs
index d5ddd16..e24aaa8 100644
--- a/askama_derive/src/generator.rs
+++ b/askama_derive/src/generator.rs
@@ -292,8 +292,10 @@ impl<'a> Generator<'a> {
self.writeln("}");
}
- fn handle_include(&mut self, ws: &WS, src: &str) {
+ fn handle_include(&mut self, ws: &WS, path: &str) {
self.prepare_ws(ws);
+ let path = path::find_template_from_path(&path, None);
+ let src = path::get_template_source(&path);
let nodes = parser::parse(&src);
let mut gen = self.child();
gen.handle(&nodes);
@@ -319,8 +321,8 @@ impl<'a> Generator<'a> {
Node::BlockDef(ref ws1, name, ref block_nodes, ref ws2) => {
self.write_block_def(ws1, name, block_nodes, ws2);
}
- Node::Include(ref ws, ref src) => {
- self.handle_include(ws, src);
+ Node::Include(ref ws, ref path) => {
+ self.handle_include(ws, path);
},
Node::Extends(_) => {
panic!("no extends or block definition allowed in content");