My favorites | Sign in
Project Home Downloads Wiki Issues Source
READ-ONLY: This project has been archived. For more information see this post.
Search
for
  Advanced search   Search tips   Subscriptions

Issue 59 attachment: template-3.html (1.0 KB)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
<html>
<head>
<script type="text/javascript" src="json-template.js">
</script>
<script type="text/javascript">

function write()
{
var t = jsontemplate.Template("{# This is a comment and will be removed from the output.}\n\n <p> Found before {.if before?} yes {.or} no {.end} </p>\n", {more_predicates: more_predicates});
var s = t.expand( {"before": 1} );
document.getElementById("replace").innerHTML = s;
}

function more_predicates(predicate_name){
if (predicate_name.match(/^before\?/)) {
return function(unused, context){
try {
return context.get('before');
}
catch(err) {
if (err.name == 'UndefinedVariable') {
return false;
}
else {
throw err;
}
}
}
}
}

</script>
</head>
<body onload="write();">
<h4>Here is the same example rendered in JavaScript. <b>View Source</b> to
see how it works.</h4>
<div id="replace"></div>
</body>
</html>
Powered by Google Project Hosting