Skip to content
This repository has been archived by the owner on Feb 7, 2023. It is now read-only.

link variable not work #1

Open
ensk opened this issue May 12, 2015 · 6 comments
Open

link variable not work #1

ensk opened this issue May 12, 2015 · 6 comments
Assignees
Labels

Comments

@ensk
Copy link

ensk commented May 12, 2015

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

@dmolsen dmolsen self-assigned this May 12, 2015
@dmolsen dmolsen added the bug label May 12, 2015
@dmolsen
Copy link
Member

dmolsen commented May 12, 2015

@ensk -

I'll look into this. Thanks for the heads up.

@ensk
Copy link
Author

ensk commented 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
Copy link

TxHawks commented May 12, 2015

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

@TxHawks
Copy link

TxHawks commented May 14, 2015

@dmolsen -

Any reason why DataLinkExporter.php in patternlab-php-core has:

$value = "../../".$patternStoreData["pathDash"]."/".$patternStoreData["pathDash"].".html";

Rather than:

$value = "../".$patternStoreData["pathDash"]."/".$patternStoreData["pathDash"].".html";

../../ points links to / instead of /patterns/.

@dmolsen
Copy link
Member

dmolsen commented 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
Copy link

TxHawks commented May 20, 2015

@dmolsen -

I fixed this by locally changing DataLinkExporter.php from:

$value = "../../".$patternStoreData["pathDash"]."/".$patternStoreData["pathDash"].".html";

to:

$value = "../".$patternStoreData["pathDash"]."/".$patternStoreData["pathDash"].".html";

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?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants