Question

I have a parent template that receives the following context:

{
users: 
[
    {
        userId: "18288128",
        group: "User 1 Group Name",
        userVideos: [{ id: 1, name: "Video1"},
                     { id: 2, name: "Video2"},
                     { id: 3, name: "Video3"}]
    },
    {
        userId: "1232412",
        group: "User 2 Group Name",
        userVideos: [{ id: 4, name: "Video93"},
                     { id: 5, name: "Video384"},
                     { id: 6, name: "Video483"}]
    },
    {
        userId: "1231231",
        group: "User 3 Group Name",
        userVideos: [{ id: 7, name: "VideoA"},
                     { id: 8, name: "VideoB"},
                     { id: 9, name: "VideoC"}]
    }
]
}

This is the parent template:

{#users}
  {! Here I want to add the partial video_list passing the correct parameters (uniqueId, groupName and the video list) !}
  {>video_list /}
{/users}

This is the partial video_list:

UniqueId: {uniqueId}{~n}
GroupName: {groupName}{~n}
<ul>
  {#videos}
<li>{name}</li>{~n}
  {/videos}
</ul>

How can I call the partial from the parent template e pass the parameters uniqueId=userId, groupName=group and videos=userVideos (this is a list).

Was it helpful?

Solution

Partials accept parameters, so you can do something like this:

{>video_list uniqueId=userId groupName=group videos=userVideos/}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top