File: tests/1.html

Recommend this page to a friend!
  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: 9 years ago
Size: 1,218 bytes


Class file image Download
<html lang="en">
	<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>

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

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

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

<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..'}

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