fn write_block(&mut self, buf: &mut Buffer, name: Option<&'a str>, outer: WS) {
        // Flush preceding whitespace according to the outer WS spec
        self.flush_ws(buf, outer);

        let prev_block = self.super_block;
        let cur = match (name, prev_block) {
            // The top-level context contains a block definition
            (Some(cur_name), None) => (cur_name, 0),
            // A block definition contains a block definition of the same name
            (Some(cur_name), Some((prev_name, _))) if cur_name == prev_name => {
                panic!("cannot define recursive blocks ({})", cur_name)
            }
            // A block definition contains a definition of another block
            (Some(cur_name), Some((_, _))) => (cur_name, 0),
            // `super()` was called inside a block
            (None, Some((prev_name, gen))) => (prev_name, gen + 1),
            // `super()` is called from outside a block
            (None, None) => panic!("cannot call 'super()' outside block"),
        };
        self.super_block = Some(cur);

        // Get the block definition from the heritage chain
        let heritage = self
            .heritage
            .as_ref()
            .unwrap_or_else(|| panic!("no block ancestors available"));
        let (ctx, def) = heritage.blocks[cur.0]
            .get(cur.1)
            .unwrap_or_else(|| match name {
                None => panic!("no super() block found for block '{}'", cur.0),
                Some(name) => panic!("no block found for name '{}'", name),
            });

        // Get the nodes and whitespace suppression data from the block definition
        let (ws1, nodes, ws2) = if let Node::BlockDef(ws1, _, nodes, ws2) = def {
            (ws1, nodes, ws2)
        } else {
            unreachable!()
        };

        // Handle inner whitespace suppression spec and process block nodes
        self.prepare_ws(*ws1);
        self.locals.push();
        self.handle(ctx, nodes, buf, AstLevel::Block);
        self.locals.pop();
        self.flush_ws(buf, *ws2);

        // Restore original block context and set whitespace suppression for
        // succeeding whitespace according to the outer WS spec
        self.super_block = prev_block;
        self.prepare_ws(outer);
    }
// If `name` is `Some`, this is a call to a block definition, and we have to find
// the first block for that name from the ancestry chain. If name is `None`, this
// is from a `super()` call, and we can get the name from `self.super_block`.
If `name` is `Some`, this is a call to a block definition, and we have to find
the first block for that name from the ancestry chain.
If ` name ` is ` Some ` this is a call to a block definition and we have to find the first block for that name from the ancestry chain .
fn write_block(&mut self, buf: &mut Buffer, name: Option<&'a str>, outer: WS) {
        // Flush preceding whitespace according to the outer WS spec
        self.flush_ws(buf, outer);
        let prev_block = self.super_block;
        let cur = match (name, prev_block) {
            // The top-level context contains a block definition
            (Some(cur_name), None) => (cur_name, 0),
            // A block definition contains a block definition of the same name
            (Some(cur_name), Some((prev_name, _))) if cur_name == prev_name => {
                panic!("cannot define recursive blocks ({})", cur_name)
            }
            // A block definition contains a definition of another block
            (Some(cur_name), Some((_, _))) => (cur_name, 0),
            // `super()` was called inside a block
            (None, Some((prev_name, gen))) => (prev_name, gen + 1),
            // `super()` is called from outside a block
            (None, None) => panic!("cannot call 'super()' outside block"),
        };
        self.super_block = Some(cur);
        // Get the block definition from the heritage chain
        let heritage = self
            .heritage
            .as_ref()
            .unwrap_or_else(|| panic!("no block ancestors available"));
        let (ctx, def) = heritage.blocks[cur.0]
            .get(cur.1)
            .unwrap_or_else(|| match name {
                None => panic!("no super() block found for block '{}'", cur.0),
                Some(name) => panic!("no block found for name '{}'", name),
            });
        // Get the nodes and whitespace suppression data from the block definition
        let (ws1, nodes, ws2) = if let Node::BlockDef(ws1, _, nodes, ws2) = def {
            (ws1, nodes, ws2)
        } else {
            unreachable!()
        };
        // Handle inner whitespace suppression spec and process block nodes
        self.prepare_ws(*ws1);
        self.locals.push();
        self.handle(ctx, nodes, buf, AstLevel::Block);
        self.locals.pop();
        self.flush_ws(buf, *ws2);
        // Restore original block context and set whitespace suppression for
        // succeeding whitespace according to the outer WS spec
        self.super_block = prev_block;
        self.prepare_ws(outer);
    }
fn write_block ( & mut self , buf : & mut Buffer , name : Option < & ' a str > , outer : WS ) { // Flush preceding whitespace according to the outer WS spec self . flush_ws ( buf , outer ) ; let prev_block = self . super_block ; let cur = match ( name , prev_block ) { // The top-level context contains a block definition ( Some ( cur_name ) , None ) => ( cur_name , 0 ) , // A block definition contains a block definition of the same name ( Some ( cur_name ) , Some ( ( prev_name , _ ) ) ) if cur_name == prev_name => { panic ! ( " " cur_name ) } // A block definition contains a definition of another block ( Some ( cur_name ) , Some ( ( _ , _ ) ) ) => ( cur_name , 0 ) , // `super()` was called inside a block ( None , Some ( ( prev_name , gen ) ) ) => ( prev_name , gen + 1 ) , // `super()` is called from outside a block ( None , None ) => panic ! ( " " ) , } ; self . super_block = Some ( cur ) ; // Get the block definition from the heritage chain let heritage = self . heritage . as_ref ( ) . unwrap_or_else ( | | panic ! ( " " ) ) ; let ( ctx , def ) = heritage . blocks [ cur . 0 ] . get ( cur . 1 ) . unwrap_or_else ( | | match name { None => panic ! ( " " cur 0 ) , Some ( name ) => panic ! ( " " name ) , } ) ; // Get the nodes and whitespace suppression data from the block definition let ( ws1 , nodes , ws2 ) = if let Node :: BlockDef ( ws1 , _ , nodes , ws2 ) = def { ( ws1 , nodes , ws2 ) } else { unreachable ! ( ) } ; // Handle inner whitespace suppression spec and process block nodes self . prepare_ws ( * ws1 ) ; self . locals . push ( ) ; self . handle ( ctx , nodes , buf , AstLevel :: Block ) ; self . locals . pop ( ) ; self . flush_ws ( buf , * ws2 ) ; // Restore original block context and set whitespace suppression for // succeeding whitespace according to the outer WS spec self . super_block = prev_block ; self . prepare_ws ( outer ) ; }
If `name` is `Some`, this is a call to a block definition, and we have to find
the first block for that name from the ancestry chain.
If ` name ` is ` Some ` this is a call to a block definition and we have to find the first block for that name from the ancestry chain .
&mut self
buf
&mut Buffer
name
Option<&'a str>
outer
WS
&mut self
buf
&mut Buffer
name
Option<&'a str>
outer
WS