harttle / liquidjs

A simple, expressive, safe and Shopify compatible template engine in pure JavaScript.
https://liquidjs.com
MIT License
1.52k stars 238 forks source link

how to stringify a parsed template #650

Closed amit777 closed 1 year ago

amit777 commented 1 year ago

Is it possible to stringify a parsed template back to the template string? I'm not looking to render the template with data. I'm looking to validate and format the liquid tags. So if someone enters {% if foo=="bar" %}FOO{% endif %} I want it to put spaces around the == or cleanup other spacing stuff within the liquid tags.

harttle commented 1 year ago

This is related to a bigger topic about linters/formatters/AST explorers for Liquid template syntax.

In short, currently templates are parsed into internal objects, and the internal structure for tags attributes is defined by each tag. Thus we don't have a universal way to stringify parsed objects.

Let's move to this topic: #528, closing this issue.