aboutsummaryrefslogtreecommitdiffstats
path: root/askama_derive/src/generator.rs
diff options
context:
space:
mode:
authorLibravatar Dirkjan Ochtman <dirkjan@ochtman.nl>2018-06-22 20:34:17 +0200
committerLibravatar Dirkjan Ochtman <dirkjan@ochtman.nl>2018-06-22 20:34:17 +0200
commitfc78b97cbc88ffd53149415e2f6201103949e04b (patch)
treea6931455073a48aabd8bee079e975a7c5ae9cbee /askama_derive/src/generator.rs
parent81141178a6e32579a34118a3deb64350272f6d2d (diff)
downloadaskama-fc78b97cbc88ffd53149415e2f6201103949e04b.tar.gz
askama-fc78b97cbc88ffd53149415e2f6201103949e04b.tar.bz2
askama-fc78b97cbc88ffd53149415e2f6201103949e04b.zip
Add some comments to describe code generator state
Diffstat (limited to 'askama_derive/src/generator.rs')
-rw-r--r--askama_derive/src/generator.rs15
1 files changed, 15 insertions, 0 deletions
diff --git a/askama_derive/src/generator.rs b/askama_derive/src/generator.rs
index 4eb62e0..86ccfd3 100644
--- a/askama_derive/src/generator.rs
+++ b/askama_derive/src/generator.rs
@@ -18,16 +18,31 @@ pub(crate) fn generate(input: &TemplateInput, contexts: &HashMap<&PathBuf, Conte
}
struct Generator<'a> {
+ // The template input state: original struct AST and attributes
input: &'a TemplateInput<'a>,
+ // All contexts, keyed by the package-relative template path
contexts: &'a HashMap<&'a PathBuf, Context<'a>>,
+ // The buffer to generate the code into
buf: String,
+ // The current level of indentation (in spaces)
indent: u8,
+ // Whether the output buffer is currently at the start of a line
start: bool,
+ // Variables accessible directly from the current scope (not redirected to context)
locals: SetChain<'a, &'a str>,
+ // Suffix whitespace from the previous literal. Will be flushed to the
+ // output buffer unless suppressed by whitespace suppression on the next
+ // non-literal.
next_ws: Option<&'a str>,
+ // Whitespace suppression from the previous non-literal. Will be used to
+ // determine whether to flush prefix whitespace from the next literal.
skip_ws: bool,
+ // Counter for askama-internal variable names allocated during code gen
vars: usize,
+ // If currently in a block, this will contain the name of a potential parent block
super_block: Option<String>,
+ // If the super macro is used; this determines whether code for the parent block
+ // is generated or not.
used_super: bool,
}