liquid icon indicating copy to clipboard operation
liquid copied to clipboard

Is it possible to get the raw markup from a liquid block?

Open artyrcheek opened this issue 3 years ago • 0 comments

Situation

I am in an unusual situation in that i am wanting to use liquid to wrap my markup in a html element and keep the raw markup inside; including the {{ and }}'s, the reason being i am allowing merchants to create their own templates for listings to be dynamically rendered back from the server, so they can define their template once, then all listings returned back will use that template.

I would like for this functionality be abstracted away so that they can just wrap their template in a liquid block, then that liquid block will be turned into a html wrapper i can the read and send to my server with js.

However when i create a new Liquid::Block class it seems i can only call super to get the parsed version of the markup within, is there anyway i can get the raw liquid inside the block?

My block has the name listing and i have noticed i can call it like this

{% listing %}
  {% raw %}
    {{ foo.bar }}
  {% endraw %}
{% endlisting %}

to read the raw content within, however this is not ideal, i would much prefer if my listing block class, could just read the raw markup itself, is this possible?

artyrcheek avatar Jan 31 '22 18:01 artyrcheek