help me in changing id of the template root

13 views
Skip to first unread message

rj

unread,
Jan 15, 2012, 6:00:00 AM1/15/12
to JavaScript Templates Engine PURE
Hi,

I am trying to produce

<div class="page" id="1"></div>
<div class="page" id="2"></div>

using the template

<div class="page"></div>

this can be done with extra div, but in my project i have constraint
of not wrapping in an extra div.

below is the code.

Thanking you in anticipation.



<html>
<head>
<title>PURE Unobtrusive Rendering Engine</title>
<script src="jquery.js"></script>
<script src="pure.js"></script>
</head>
<body>
<!-- HTML template -->
<div class="page"></div>

<script>
var directive = {
'.' : {
'page<-pages' : {
'@id' : function(arg){
return this.no;
}
}
}
};

var data = {
"pages" : [
{'no' : '1'},
{'no' : '2'}
]

};

$('div.page').render(data, directive);
</script>
</body>

Mic (BeeBole)

unread,
Jan 25, 2012, 4:46:00 PM1/25/12
to JavaScript Templates Engine PURE
Hi rj,

Sorry for the delay. You were moderated and I didn't receive an email
informing me to approve it.

You can't loop on the root.
You can work in memory, render the template for instance in a document
fragment.
And replace the node with the loop result.
Reply all
Reply to author
Forward
0 new messages