alonrbar/easy-template-x

Is it possible to create links from an array with a loop?

Closed this issue · 2 comments

Hello,
I need to create links from a links array, is this possible?
Thanks

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

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!