Shopify / liquid

Liquid markup language. Safe, customer facing template language for flexible web apps.

Home Page:https://shopify.github.io/liquid/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Deprecate variableLookups on LHS of assign.

charlespwd opened this issue · comments

This is obscure and we do support it but behaves rather strangely. We should deprecate this.

{% assign product.img = "hi" %}

{% # prints nothing %}
{{ product.img }}

{% # prints "hi" %}
{{ ["product.img"] }}

It's because we parse the entire assign LHS as a string and then assign the context's <stringValueOfLHS> to be the value of the RHS. And our VariableSegment regex accepts dots and square brackets.

context.scopes.last[@to] = val

Syntax = /(#{VariableSignature}+)\s*=\s*(.*)\s*/om

VariableSignature = /\(?[\w\-\.\[\]]\)?/

While we're there, we should probably cleanup our regex for variable segment, variable signature, etc.