File: tests/7.html

Recommend this page to a friend!
  Classes of Aliaksandr Astashenkau  >  Templ  >  tests/7.html  >  Download  
File: tests/7.html
Role: Example script
Content type: text/plain
Description: If-block inside for-loop
Class: Templ
Processes templates embedded in the pages
Author: By
Last change:
Date: 8 years ago
Size: 1,266 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>

	If-block inside for-loop
	<a href="index.html" class="back">Back to tests</a>

<script type="html/template" id="tpl_example">
    {% for r in records %}
            <h3>{{ r.title }}</h3>
            {% if r.features & _act.VIEW %}<a href="!#view/{{ r.id }}">View</a>{% endif %}
            {% if r.features & _act.MARK %}<a href="!#mark/{{ r.id }}">Mark</a>{% endif %}
            {% if r.features & _act.REMOVE %}<a href="!#remove/{{ r.id }}">Remove</a>{% endif %}
    {% endfor %}

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

<pre id="data">
        _act: {
            VIEW: 1,
            MARK: 2,
            REMOVE: 4
        records: [
            {id: 5, title: 'Search options', features: 7},
            {id: 6, title: 'Default actions', features: 5}

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