Passing JSON data in pattern | PatternLab

590 views Asked by At

I want to include an atomic pattern and want to pass data from a JSON array below is code and JSON file.

anchor-link.mustache

<a href="{{ url }}" class="{{ class }}">{{ label }}</a>

footer-nav.mustache

<ul class="menu vertical">
{{# footerNav }}
    <li>{{> atoms-anchor-link(url:url, label : label, class : class) }}</li>
{{/ footerNav }}
</ul>

JSON from where i want to populate anchor mustache

{
    "footerNav": [{
        "label": "Shop",
        "url": "#",
        "class": "body-copy"
    }, {
        "label": "Pods",
        "url": "#",
        "class": "all-caps-large"
    }]
}

Output

<ul class="menu vertical">
    <li><a href="" class=""></a>
</li>
    <li><a href="" class=""></a>
</li>
</ul>

Pattern Lab is generating correct HTML and creates anchors but no values are populating in anchors.

Thanks in advance!!!!

1

There are 1 answers

0
VIKAS VERMA On BEST ANSWER

You have called wrong pattern here.

<li>{{> atoms-anchor-link(url:url, label : label, class : class) }}</li>

Correct pattern is.

<li>{{> atoms-anchor-link}}</li>

This will work.