Skip to content

Commit

Permalink
fix(comment_block): allow nesting
Browse files Browse the repository at this point in the history
The test still doesn't pass because of the current strictness in grammar.pest

fixes #281
  • Loading branch information
Goncalerta committed Dec 1, 2018
1 parent 9235289 commit 8d1f64e
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/tags/comment_block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use std::io::Write;

use liquid_error::Result;

use compiler::BlockElement;
use compiler::LiquidOptions;
use compiler::TagBlock;
use compiler::TagTokenIter;
Expand All @@ -18,15 +19,23 @@ impl Renderable for Comment {
}

pub fn comment_block(
_tag_name: &str,
tag_name: &str,
mut arguments: TagTokenIter,
mut tokens: TagBlock,
_options: &LiquidOptions,
options: &LiquidOptions,
) -> Result<Box<Renderable>> {
// no arguments should be supplied, trying to supply them is an error
arguments.expect_nothing()?;

while tokens.next()?.is_some() {}
while let Some(token) = tokens.next()? {
// Only parse `{% comment %}` tags (in order to allow nesting)
if let BlockElement::Tag(tag) = token {
if tag.name() == tag_name {
tag.parse(&mut tokens, options)?;
}
}
}

tokens.assert_empty();
Ok(Box::new(Comment))
}
Expand Down

0 comments on commit 8d1f64e

Please sign in to comment.