Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds break and continue tags. #26

Merged
merged 1 commit into from
Mar 29, 2016
Merged

Conversation

tcsc
Copy link
Contributor

@tcsc tcsc commented Mar 25, 2016

Adds the notion of an "interrupt" - a signal in the rendering context that stops all rendering and returns the rendered content back up the call stack. When the stack unwind hits a for_loop, it resets the
interrupt and continues processing as directed - either breaking out of the loop or continuing on to the next iteration.

The break and continue tags are then implemented on top of this interrupt construct. This is pretty much how the shopify implementation handles the same problem.

Also adds support for nested tags in the parser (e.g. nested for_loop, if, etc). Prior to this, the parser would truncate the children at the inner end tag.

},
_ => {}
}
};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you quickly elaborate (and maybe write a short comment) why you need to collect the nesting_depth here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah, clever indeed

@johannhof
Copy link
Contributor

Mmh, this one is a bit tricky. I'm usually not a big fan of changing things all around the code to support a single tag. But in this case there really seems to be no better alternative. I left a few minor comments :)

Adds the notion of an "interrupt" - a signal in the rendering context
that stops all rendering and returns the rendered content back up the
call stack. When the stack unwind hits a for_loop, it resets the
interrupt and continues processing as directed - either breaking out
of the loop or continuing on to the next iteration.
@johannhof
Copy link
Contributor

👍 great, thanks!

@johannhof johannhof merged commit 5d9ffd4 into cobalt-org:master Mar 29, 2016
@tcsc tcsc deleted the interrupts branch March 30, 2016 02:21
epage added a commit to epage/liquid-rust that referenced this pull request Feb 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants