shopifyliquidauth0liquid-template

How to assign a hashmap to a variable in Liquid Templates?


Is it possible to assign a Hashmap to a variable in this manner:

{% assign translations = {en: 'Hello', es: 'Hola'} %}

And then access it like this:

{{ translations.en }}

It seems possible from this question but accessing the translations variable yields empty string.


Solution

  • I researched further and it seems that variables in Liquid can only be assigned basic data types like strings, numbers and booleans.

    As for objects and arrays, they can only be provided by the underlying platform (I think) like Shopify, Auth0 Azure ...etc. Which seems to conform with this requirement (ref):

    [...]. You don't want your server running code that your users wrote.