Login   Register  
Icontem

File: tests/1.html

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Aliaksandr Astashenkau  >  Templ  >  tests/1.html  >  Download  
File: tests/1.html
Role: Example script
Content type: text/plain
Description: Simple variable marker and for-loop
Class: Templ
Processes templates embedded in the pages
Author: By
Last change:
Date: 2011-07-01 04:47
Size: 1,218 bytes
 

Contents

Class file image Download
<!DOCTYPE HTML>
<html lang="en">
<head>
	<title>Templ test</title>
	<meta charset="UTF-8">
	<link rel="stylesheet" href="style.css">
	<script type="text/javascript" src="utils.js"></script>
	<script type="text/javascript" src="../templ.js"></script>
</head>
<body>

<h2>
	Simple variable marker and for-loop
	<a href="index.html" class="back">Back to tests</a>
</h2>

<script type="html/template" id="tpl_example">
    <h1>{{ title }}</h1>
    <ul>
        {% for key, comment in comments %}
        <li>
            <div><b>{{ comment.author }}</b>, {{ comment.date }}</div>
            <div>{{ comment.text }}</div>
        </li>
        {% else %}
        <li>No comments</li>
        {% endfor %}
    </ul>
</script>

<h3>Template</h3>
<pre id="template"></pre>

<h3>Data</h3>
<pre id="data">
    {
        title: 'Comment list',
        comments: [
            {author: 'Wiki Baum', date: '2011-07-04', text: 'Gravitation is responsible for keeping the Earth in its orbit around the Sun.'},
            {author: 'Tim Ro', date: '2011-06-14', text: 'Althoug it is time to go..'}
        ]
    }
</pre>

<h3>Parsed result</h3>
<pre id="output"></pre>

</body>
</html>