Skip to content

Add Better Parse Warnings To recursive-parser Branch - #244

Merged
trishume merged 8 commits into
recursive-parsingfrom
proper-parse-warnings
Aug 27, 2013
Merged

trishume merged 8 commits into
recursive-parsingfrom
proper-parse-warnings

Conversation

@trishume

Copy link
Copy Markdown
Contributor

@fw42 @arthurnn
Allows the warnings to be retrieved in :warn mode without rendering the template.
Links up all the tags in a proper parse tree where each tag has links to all its children so it can recursively get information from them.
Note that this PR merges into the recursive-parsing branch.

This is necessary for situations where you want to verify a template is syntactically correct and issue warnings if it is not but without rendering it, such as a template editor.

@fw42

fw42 commented Aug 22, 2013

Copy link
Copy Markdown
Contributor

Wouldn't it be easier to just render the template to get the warnings? :-)

Comment thread lib/liquid/block.rb

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why do we need this if we already have @nodelist?

@trishume

Copy link
Copy Markdown
Contributor Author

@nodelist gets modified by the tags, for example if wrecks it and so do many other tags. It also contains text nodes as well as tags.

Rendering the template is not a good option because then you could get other errors from missing filters or bad dummy data. Also performance.

Comment thread lib/liquid/block.rb Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I believe this is always true (since @children is never nil or false)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This is to guard against calling warnings before parsing, but you're right, parse is called on initialization so that can't happen.

@trishume

Copy link
Copy Markdown
Contributor Author

Ok fixed all the issues, how's it look now?

@trishume

Copy link
Copy Markdown
Contributor Author

@fw42 is this OK to merge into the recursive-parsing branch?

@fw42

fw42 commented Aug 26, 2013

Copy link
Copy Markdown
Contributor

Since this is also affecting the non-strict parser, can I get a performance benchmark?

Comment thread lib/liquid/template.rb Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think that comment is unnecessary

@fw42

fw42 commented Aug 26, 2013

Copy link
Copy Markdown
Contributor

Code looks good. Merge it.

trishume added a commit that referenced this pull request Aug 27, 2013
Add Better Parse Warnings To recursive-parser Branch
@trishume
trishume merged commit 26eb9a0 into recursive-parsing Aug 27, 2013
@trishume
trishume deleted the proper-parse-warnings branch August 27, 2013 13:53
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