You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Feb 7, 2023. It is now read-only.
when I try to create links to patterns as i did with patternlab + mustache {{ link.templates-mypattern }} fails, returns 0. I think it is because twig handle{{ link.templates }} as a simple variable and not like it should be
I think it's a problem with "-" because something similar happens when add a new value in data.json named my-var returns 0, but if I name my_var return the expected value. with the default values in data.json has a normal behavior
It is probably the -. Since {{ }} in Twig is the print statement, anything inside it will be interpreted, so -s are treated as the minus operator. Basically, Twig is trying to subtract mypattern from link.templates.
A workaround would be to use the built-in attribute function like this: {{ attribute(link, 'templates-mypattern') }}
This sort of works. The variable gets interpreted right, but the link points to one step too high in the directory hierarchy. E.g. ../../03-templates-00-mypattern/03-templates-00-mypattern.html instead of ../03-templates-00-mypattern/03-templates-00-mypattern.html
The issue is indeed related to the dash for the reasons @TxHawks notes. His solution is also the appropriate one. I'll leave this open until I can check out the separate issue he reported. I'm assuming it was just something stupid on my part.
Activity
dmolsen commentedon May 12, 2015
@ensk -
I'll look into this. Thanks for the heads up.
ensk commentedon May 12, 2015
I think it's a problem with "-" because something similar happens when add a new value in data.json named my-var returns 0, but if I name my_var return the expected value. with the default values in data.json has a normal behavior
TxHawks commentedon May 12, 2015
It is probably the
-
. Since{{ }}
in Twig is theprint
statement, anything inside it will be interpreted, so-
s are treated as theminus
operator. Basically, Twig is trying to subtractmypattern
fromlink.templates
.A workaround would be to use the built-in
attribute
function like this:{{ attribute(link, 'templates-mypattern') }}
This sort of works. The variable gets interpreted right, but the link points to one step too high in the directory hierarchy. E.g.
../../03-templates-00-mypattern/03-templates-00-mypattern.html
instead of../03-templates-00-mypattern/03-templates-00-mypattern.html
TxHawks commentedon May 14, 2015
@dmolsen -
Any reason why DataLinkExporter.php in patternlab-php-core has:
Rather than:
../../
points links to/
instead of/patterns/
.dmolsen commentedon May 14, 2015
@ensk -
The issue is indeed related to the dash for the reasons @TxHawks notes. His solution is also the appropriate one. I'll leave this open until I can check out the separate issue he reported. I'm assuming it was just something stupid on my part.
TxHawks commentedon May 20, 2015
@dmolsen -
I fixed this by locally changing DataLinkExporter.php from:
to:
Tried to test it with the Mustache edition, but couldn't install pattern-lab/edition-php-development#13.
Do you want a pull request on that?