Liquid Parser Inside Text Based Files

Liquid (and module rendering) inside other text based files such as .css, .js, .xml, .json, .txt, etc.
Add “.liquid” suffix to the file URL to force it to be processed by the liquid engine.

Example

File:
/assets/css/main.css
In order to parse file by liquid first use such link:
/assets/css/main.css.liquid


@Peter-Schmidt Can you please attach this forum post to this backlog item https://portal.treepl.co/backlog/2092

I think it would be worth having some additional conversation around this feature. I think it could be really powerful.

@Adam.Wilson I recall that you generated this idea originally.

@TimL I think that it was mentioned that this functionality could address a JSON use case.

I would love to see anybody else’s input on what the possibilities with this feature could be. I mean it really opens up some interesting possibilities.

It’s pretty interesting to think about dynamically influencing .css with liquid logic. You could make changes based on the context in which CSS is called. The idea of mixing liquid and js in an external js file is pretty interesting. You could theoretically call a module in a .js file, pull in values and pass them to the JS. It’s pretty wild west.

I’m trying to think of some specific use cases. If somebody can come up with some I’d be interested to hear them.

2 Likes

@Alex_B_Centrifuge - Sure, added :+1:

I would definitely use this, as I already use this in Shopify. A case where I would use this is in Treepl through a Custom Google Map. Currently, I add the Map JS info in a snippet (all scripts), and add my Module Looping in that file. Works well, but for me, that is one more script file to load. I prefer to just have 1 or 2 JS files to load, so if I can eliminate this JS file, and include the liquid looping in my main .js file that would be amazing.

Cheers,
Aaron

1 Like

Overall use cases I can think of:

  • dynamic CSS and JS files (even concatenate multiple files into one)
  • various feeds for external systems (ie: RSS, XML, JSON, KML, even CSV…)
  • generate configuration files for use locally (or externally), say for a plugin or your own custom project.
1 Like