Replies: 1 comment
-
I figured this out. We can simply use |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I've been looking for a way to output the variable tag itself if it is not available when compiling the template. So if
strictVariables=true
throws an error andstrictVariables=false
renders an empty string when the variable does not exist, this option would not try to compile it and leave the liquid syntax in the output.It's like a pre-compilation state. The goal is to have the developers create distinct sections/partials with their own variables that can be set. In
new_page/index.liquid
, they couldrender
the different sections via{% render 'section1.liquid', color: 'blue' %} {% render 'section4.liquid', bob: 'is your uncle' %}
.section1.liquid
might have a variable{{ customer_first_name }}
in addition to the scoped variablecolor: 'blue'
. Thenew_page/index.liquid
is intended to be a template itself which can be later compiled with the actual value of{{ customer_first_name }}
.I considered using a Proxy (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy) to catch any missing variables and output
{{ customer_first_name }}
instead of losing the tag when it was compiled to an empty string. I think this could work unless there is a condition on{{ customer_first_name }}
.Is there anything in liquidjs that would allow skipping the compilation of undefined variables and outputting the code/variable/condition instead? Any alternative suggestions for solving the problem are greatly appreciated. It's not currently possible (without a significant amount of effort) to host all the sections/partials separately at the final render time. I'm building a tool to interact with a different app that expects a single liquid template input.
Beta Was this translation helpful? Give feedback.
All reactions