fn handle(&mut self, ctx: &'a Context, nodes: &'a [Node], buf: &mut Buffer, level: AstLevel) {
        for n in nodes {
            match *n {
                Node::Lit(lws, val, rws) => {
                    self.write_lit(buf, lws, val, rws);
                }
                Node::Comment(ws) => {
                    self.write_comment(buf, ws);
                }
                Node::Expr(ws, ref val) => {
                    self.write_expr(buf, ws, val);
                }
                Node::LetDecl(ws, ref var) => {
                    self.write_let_decl(buf, ws, var);
                }
                Node::Let(ws, ref var, ref val) => {
                    self.write_let(buf, ws, var, val);
                }
                Node::Cond(ref conds, ws) => {
                    self.write_cond(ctx, buf, conds, ws);
                }
                Node::Match(ws1, ref expr, inter, ref arms, ws2) => {
                    self.write_match(ctx, buf, ws1, expr, inter, arms, ws2);
                }
                Node::Loop(ws1, ref var, ref iter, ref body, ws2) => {
                    self.write_loop(ctx, buf, ws1, var, iter, body, ws2);
                }
                Node::BlockDef(ws1, name, _, ws2) => {
                    if AstLevel::Nested == level {
                        panic!(
                            "blocks ('{}') are only allowed at the top level of a template \
                             or another block",
                            name
                        );
                    }
                    let outer = WS(ws1.0, ws2.1);
                    self.write_block(buf, Some(name), outer);
                }
                Node::Include(ws, path) => {
                    self.handle_include(ctx, buf, ws, path);
                }
                Node::Call(ws, scope, name, ref args) => {
                    self.write_call(ctx, buf, ws, scope, name, args);
                }
                Node::Macro(_, ref m) => {
                    if level != AstLevel::Top {
                        panic!("macro blocks only allowed at the top level");
                    }
                    self.flush_ws(buf, m.ws1);
                    self.prepare_ws(m.ws2);
                }
                Node::Import(ws, _, _) => {
                    if level != AstLevel::Top {
                        panic!("import blocks only allowed at the top level");
                    }
                    self.handle_ws(buf, ws);
                }
                Node::Extends(_) => {
                    if level != AstLevel::Top {
                        panic!("extend blocks only allowed at the top level");
                    }
                    // No whitespace handling: child template top-level is not used,
                    // except for the blocks defined in it.
                }
            }
        }
    }
/* Helper methods for handling node types */
Helper methods for handling node types
Helper methods for handling node types
fn handle(&mut self, ctx: &'a Context, nodes: &'a [Node], buf: &mut Buffer, level: AstLevel) {
        for n in nodes {
            match *n {
                Node::Lit(lws, val, rws) => {
                    self.write_lit(buf, lws, val, rws);
                }
                Node::Comment(ws) => {
                    self.write_comment(buf, ws);
                }
                Node::Expr(ws, ref val) => {
                    self.write_expr(buf, ws, val);
                }
                Node::LetDecl(ws, ref var) => {
                    self.write_let_decl(buf, ws, var);
                }
                Node::Let(ws, ref var, ref val) => {
                    self.write_let(buf, ws, var, val);
                }
                Node::Cond(ref conds, ws) => {
                    self.write_cond(ctx, buf, conds, ws);
                }
                Node::Match(ws1, ref expr, inter, ref arms, ws2) => {
                    self.write_match(ctx, buf, ws1, expr, inter, arms, ws2);
                }
                Node::Loop(ws1, ref var, ref iter, ref body, ws2) => {
                    self.write_loop(ctx, buf, ws1, var, iter, body, ws2);
                }
                Node::BlockDef(ws1, name, _, ws2) => {
                    if AstLevel::Nested == level {
                        panic!(
                            "blocks ('{}') are only allowed at the top level of a template \
                             or another block",
                            name
                        );
                    }
                    let outer = WS(ws1.0, ws2.1);
                    self.write_block(buf, Some(name), outer);
                }
                Node::Include(ws, path) => {
                    self.handle_include(ctx, buf, ws, path);
                }
                Node::Call(ws, scope, name, ref args) => {
                    self.write_call(ctx, buf, ws, scope, name, args);
                }
                Node::Macro(_, ref m) => {
                    if level != AstLevel::Top {
                        panic!("macro blocks only allowed at the top level");
                    }
                    self.flush_ws(buf, m.ws1);
                    self.prepare_ws(m.ws2);
                }
                Node::Import(ws, _, _) => {
                    if level != AstLevel::Top {
                        panic!("import blocks only allowed at the top level");
                    }
                    self.handle_ws(buf, ws);
                }
                Node::Extends(_) => {
                    if level != AstLevel::Top {
                        panic!("extend blocks only allowed at the top level");
                    }
                    // No whitespace handling: child template top-level is not used,
                    // except for the blocks defined in it.
                }
            }
        }
    }
fn handle ( & mut self , ctx : & ' a Context , nodes : & ' a [ Node ] , buf : & mut Buffer , level : AstLevel ) { for n in nodes { match * n { Node :: Lit ( lws , val , rws ) => { self . write_lit ( buf , lws , val , rws ) ; } Node :: Comment ( ws ) => { self . write_comment ( buf , ws ) ; } Node :: Expr ( ws , ref val ) => { self . write_expr ( buf , ws , val ) ; } Node :: LetDecl ( ws , ref var ) => { self . write_let_decl ( buf , ws , var ) ; } Node :: Let ( ws , ref var , ref val ) => { self . write_let ( buf , ws , var , val ) ; } Node :: Cond ( ref conds , ws ) => { self . write_cond ( ctx , buf , conds , ws ) ; } Node :: Match ( ws1 , ref expr , inter , ref arms , ws2 ) => { self . write_match ( ctx , buf , ws1 , expr , inter , arms , ws2 ) ; } Node :: Loop ( ws1 , ref var , ref iter , ref body , ws2 ) => { self . write_loop ( ctx , buf , ws1 , var , iter , body , ws2 ) ; } Node :: BlockDef ( ws1 , name , _ , ws2 ) => { if AstLevel :: Nested == level { panic ! ( " \
 " name ) ; } let outer = WS ( ws1 . 0 , ws2 . 1 ) ; self . write_block ( buf , Some ( name ) , outer ) ; } Node :: Include ( ws , path ) => { self . handle_include ( ctx , buf , ws , path ) ; } Node :: Call ( ws , scope , name , ref args ) => { self . write_call ( ctx , buf , ws , scope , name , args ) ; } Node :: Macro ( _ , ref m ) => { if level != AstLevel :: Top { panic ! ( " " ) ; } self . flush_ws ( buf , m . ws1 ) ; self . prepare_ws ( m . ws2 ) ; } Node :: Import ( ws , _ , _ ) => { if level != AstLevel :: Top { panic ! ( " " ) ; } self . handle_ws ( buf , ws ) ; } Node :: Extends ( _ ) => { if level != AstLevel :: Top { panic ! ( " " ) ; } // No whitespace handling: child template top-level is not used, // except for the blocks defined in it. } } } }
Helper methods for handling node types
Helper methods for handling node types
&mut self
ctx
&'a Context
nodes
&'a [Node]
buf
&mut Buffer
level
AstLevel
&mut self
ctx
&'a Context
nodes
&'a [Node]
buf
&mut Buffer
level
AstLevel