Hello,
I'm searching for template engine (HTML+JSON). I was testing PURE,
then I found SubtleTemplates by Thomas Aylott.
We are using mootools inhouse so I thoght it could be a better choice
but I am not sure about usage.
I have data like this:
var src = {
"?xml": {
"@version": "1.0",
"@standalone": "no"
},
"root": {
"group": [{
"@name": "Disk",
"action": [{
"@id": "document-new",
"@name": "New",
"@img-url": "img/document-new.png",
"@allowed": "1",
"@disabled": "0"
}, {
"@id": "document-open",
"@name": "Open",
"@img-url": "img/document-open.png",
"@allowed": "1",
"@disabled": "0"
}]
},{
"@name": "Printer",
"action": [{
"@id": "document-print",
"@name": "Print",
"@img-url": "img/document-print.png",
"@allowed": "1",
"@disabled": "0"
}]
}]
}
}
I need template like this:
<div id="template">
<ul id="root">
<li class="SubtleTemplate group">
<div class="@nazwa">{gro...@name}</div>
<ul>
<li class="SubtleTemplate action"><button>
<img class="@img-url"
src="{acti...@img-url}"></img>
<div
class="@name">{acti...@name}</div></button></li>
</ul>
</li>
</div>
What's the best way to convert this? Should I iterate through arrays
or can I use subtemplates? I tried but with no effect ;)
Thanks,
Robert