<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<script type="text/javascript" src="swig.min.js"></script>
<script type="text/javascript">
window.onload = function(){
var template = '{{ stuff }} {{ akg.name }} {% if stuff %} super Stuff {% endif %}';
template += '{% for person in people %}'
+ '{% if loop.first %}<ol>{% endif %}'
+ '<li>Index: {{ loop.key }} {{ person.name }}</li>'
+ '{% if loop.last %}</ol>{% endif %}'
+ '{% endfor %}';
template += '{% for item in seq -%} {{ item }} {%- endfor %}';
var locals = {locals: {
stuff: 'awesome'
, akg: {name: 'Dima'}
, people: [{name: 'One'}, {name: 'Two'}, {name: 'Three'}]
, seq: [1, 2, 3, 4, 5]
}};
var result = swig.render(template, locals);
document.body.innerHTML = result;
};
</script>
</head>
<body></body>
</html>
Комментариев нет:
Отправить комментарий