PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Friday, July 1, 2022

[FIXED] How to assign a hashmap to a variable in Liquid Templates?

 July 01, 2022     auth0, liquid, liquid-template, shopify     No comments   

Issue

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.



Answered By - Seif
Answer Checked By - Marie Seifert (PHPFixing Admin)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing