Skip to content

Looping & Templating

Min Si Thu edited this page Jul 12, 2019 · 2 revisions

Looping

TrollHunter allows looping and templating.

let state = {
    people:["john","simon","carter"]
}
let templates = {
    peopleProfile(value,index){
       return `
            <h3>${index}. ${value}</h3>
       `;
    }
}
let app = new TrollHunter(state);
app.setTemplates(templates);

In html file,

<div loop="people" template="peopleProfile"></div>
Clone this wiki locally