I’m building a theme app extension and have an app metafield like so:
{
"key": "rules",
"type": "single_line_text_field",
"value": "{% if cart.item_count > 1 %}true{% else %}false{% endif %}"
}
In the liquid file I access it like so:
{{ app.metafields.
Which just spits out the value as a string. Is there a way to force it to render as liquid? Or some other way to achieve this?
@clairemuller it totally depends on how you would like render it in liquid. For example, to use it as checked input in liquid format, you can pass the value to html input attribute:
// In your blocks/theme-app-extension.liquid
<input type="checkbox" {% if app.metafields.<app-namespace>.rules.value == True %}checked{% endif %}" />
Just as a precaution, your app metafield values can only be set by the app itself. If you are trying to watch the cart item count and want to render a particular element simply do (not sure if you need to use metafield):
// In your blocks/theme-app-extension.liquid
{% if cart.item_count > 1 %}
{% # render particular element %}
{% else %}
{% # render default element %}
{% endif %}