-
-
Notifications
You must be signed in to change notification settings - Fork 237
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
Unparse liquid object tree to liquid string #93
Comments
The It can be very tricky to understand and modify the |
I would definitely agree that modifying the object is something that would be done on a case by case basis and can be done outside the scope of this library. To clarify, the focus of this issue would be create a function, lets call it const originalTemplateString = fs.readFileSync('./template.liquid', 'utf8');
const templateObject = engine.parse(originalTemplateString);
const newTemplateString = engine.reverseRender(templateObject);
expect(newTemplateString).toEqual(originalTemplateString); |
It's great to have this feature, provided that it doesn't introduce much complexity into tags. To do this, both templates -> tokens, and tokens -> html need to be implemented.
|
Talked this over with some colleagues, instead of ‘reverseRender’, maybe ‘unparse’ works better? I can see each tag defines their own ‘parse’ and ‘render’ methods to handle their own unique data structure. How about introducing an additional method, ‘unparse()’ for each tag, which essentially does the reverse of each parse method. |
I agree liquidjs also provides a browser-side version, so hope it won't take much code 😄 |
Since |
I know it's been a while, but did you ever manage to unparse a template tree easily ? Is there any solution around ? |
Would love to be able to parse a liquid template, modify the object tree, and then reassemble to a modified template. Willing to help you if you want!
Thanks for your great work @harttle! 👏
Example
The text was updated successfully, but these errors were encountered: