Is it possible to create links from an array with a loop?
Closed this issue · 2 comments
danidz96 commented
Hello,
I need to create links from a links array, is this possible?
Thanks
alonrbar commented
Absolutely. Your template can look something like this:
{#list}{link}{/list}
And the data something like this:
{
list: [
{
link: {
_type: 'link',
target: 'http://something.com'
}
},
{
link: {
_type: 'link',
target: 'http://something.else.com'
}
}
]
}
Take a look here:
https://github.com/alonrbar/easy-template-x#loop-plugin
And here: https://github.com/alonrbar/easy-template-x#link-plugin
danidz96 commented
Absolutely. Your template can look something like this:
{#list}{link}{/list}
And the data something like this:
{ list: [ { link: { _type: 'link', target: 'http://something.com' } }, { link: { _type: 'link', target: 'http://something.else.com' } } ] }
Take a look here: https://github.com/alonrbar/easy-template-x#loop-plugin
And here: https://github.com/alonrbar/easy-template-x#link-plugin
it worked! Thank you!