Question

<span id='sitemap'> 
    {#footer.sitemaps}
    <a id="{id}" href="{url}">{@pre type="content" mode="json" key="footer.{id}"/}</a>
            {/footer.sitemaps}
</span>

In the code, {id} is a property of one element in footer.sitemaps. I want Makara to get the key value dynamically using {id}. May I know how to do that?

Was it helpful?

Solution

See the discussion around this makara issue: https://github.com/krakenjs/makara/issues/36

OTHER TIPS

Check this: https://github.com/mikesparr/Kraken_Example_i18n_Helper
You can use @bundleString helper rather than @pre. So, you can use something like {@bundleString key="footer.{id}" bundle="your_data_properties_file name"}

You can do that by using the {@provide} tag. Here is an example using yours:

{@provide}
    {#footer.sitemaps}
        <a id="{id}" href="{url}">{footerMap[id]}</a>
    {/footer.sitemaps}
{:footerMap}
    {@pre type="content" mode="json" key="footer"/}
{/provide}

If your properties file looked like

footer.key1=SomeVal
footer.key2=AnotherVal

and your footer.sitemaps data object looked like

{
    id: 'key1',
    href: 'http://my/url
}

The result of running this would be

<a id="key1" href="http://my/url">SomeVal</a>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top