bkiers / Liqp

An ANTLR based 'Liquid Template' parser and rendering engine.
MIT License
165 stars 94 forks source link

Fix 179, Includes within for loop is missing variables #180

Closed msangel closed 3 years ago

msangel commented 3 years ago

Fix for https://github.com/bkiers/Liqp/issues/179 Include has access only to the variables of the current scope, so variables from parent scopes were missing. For the fixing this added a new method to TemplateContext that returns all variables, including parent's ones, recursive and used that as a source of data for include. The new collection is a clone, so the include will not have an impact on global variables.

@bkiers, please review.

msangel commented 3 years ago

It requires more work, as, it appears, if the variable has been changed inside of included file, this change is translated to outer script