Try/Catch or Compilation Error in Liquid Conditionals #1914
Replies: 1 comment
-
👋 Hey @procarrera, Thank you for sharing this proposal! I have one question about the try/catch mechanism. I believe we could achieve the same result with the following code. Is there a scenario where a try/catch wouldn't be satisfied by this workaround? {% if section.blocks.size < 2 %}
<p style="color: red; font-weight: bold;">At least two blocks are required.</p>
{% endif %} Historically, we have aimed to avoid introducing certain low-level programming language features into Liquid to keep it as simple and human-friendly as possible. However, if we have a use case that showcases try/catch an important structure, we can certainly consider introducing it or even an alternative that may feel more idiomatic for humans (such as assertions or other alternatives). Thanks again for sharing this proposal! |
Beta Was this translation helpful? Give feedback.
-
Feature Request: Try/Catch or Compilation Error in Liquid Conditionals
Problem Statement
As our experience with Liquid, its documentation, and development deepens, we have encountered cases where enforcing certain conditions in Liquid templates would be beneficial. However, there is currently no built-in way to throw compilation errors or handle exceptions in Liquid conditionals.
Use Case
Proposed Solution
Introduce a way to:
Example
This would improve developer experience by catching issues at build time rather than failing silently.
Would love to hear thoughts on feasibility and potential workarounds in the current implementation.
Beta Was this translation helpful? Give feedback.
All reactions