I am using twig Pattern Lab includes with the longhand syntax (needed for integration reasons), aka {% include "@atoms/path/to/pattern.twig" %}
.
If I have variables defined in a pattern, and then include that pattern in another pattern, the included pattern's variables are set to null
, unless I pass in a new context with with
.
For example:
my-atom
<p>{{ myvar }}</p> {# myvar is set when viewing my-atom directly #}
my-molecule
<div>{% include "@atoms/my-atom/my-atom.twig" %}</div> {# Prints an empty <p> tag #}
<div>{% include "@atoms/my-atom/my-atom.twig" with { myvar: "Hello!" } %}</div> {# Prints "<p>Hello!</p>" #}
I would expect the variables from the molecule to flow down to the atom, falling back to the atom's values if the variable isn't defined in the molecule, similar to how the short hand syntax works (aka, {% include "atoms-my-atom" %}
).
Is this a feature? A bug? Is there something I'm missing?
Thanks so much in advance!