tyler-sommer / stick

A golang port of the Twig templating engine
MIT License
183 stars 36 forks source link

Include "with" syntax to pipe in variables doesn't work #5

Closed dave closed 8 years ago

dave commented 8 years ago

The "with" syntax detailed here that is used to inject variables into an included template doesn't seem to work:

// fragment.twig
{{ foo }}
// main.twig
{% include "fragment.twig" with {"foo": "bar"} %}

The error is:

parse: unexpected token "HASH_OPEN" on line 1, column 31
dave commented 8 years ago

However, this works:

// main.twig
{% set vars = {"foo": "bar"} %}
{% include "fragment.twig" with vars %}
tyler-sommer commented 8 years ago

Thanks! It looks like parsing the include tags doesn't allow for map literals, that will definitely have to change.

tyler-sommer commented 8 years ago

I'm happy to say that this is now implemented so I'll close this issue. Please open another issue if you run into any problems. Thanks!