Reputation: 275
<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?
Upvotes: 1
Views: 1186
Reputation: 49
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>
Upvotes: 0
Reputation: 209
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"}
Upvotes: 1
Reputation: 484
See the discussion around this makara issue: https://github.com/krakenjs/makara/issues/36
Upvotes: 2