liquid
liquid copied to clipboard
Tag formatter/syntax fixer (WIP)
Problem
People have templates with broken syntax that is accepted by the lax parser but really makes no sense. We can't switch entirely to the strict parser because of this.
Potential Solution
Add a method to convert a Liquid pseudo-AST back into Liquid source. Then, to fix broken templates, this can be run on the lax-parsed AST and written back to the template source.
Notes
This has the side effect of reformatting everything, which is arguably good or bad. It only affects the inside of tags though, so the output should definitely be the same.
Tags that don't implement format
will use the default, which is to just spit the markup back out. This is one of the motivations for #560 (unified syntax for tag arguments).
I'm not sure how to format for
and tablerow
, they accept arguments with commas and without. This is another reason for #560, there is no standard for how we treat arguments.
@fw42 @dylanahsmith @trishume thoughts? Any reason why this is a Bad Idea?