Skip to content

Commit

Permalink
Updated sample to TemplatePro 0.5 syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
danieleteti committed Sep 2, 2024
1 parent 5cdcdf8 commit b289b2f
Show file tree
Hide file tree
Showing 5 changed files with 118 additions and 99 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{{include("partials/header.tpro")}}
{{include "partials/header.tpro"}}
<script>
function doDelete(id) {
if (confirm('Are you sure?')) {
Expand All @@ -14,7 +14,7 @@
<input type="hidden" value="{{:person.guid}}" name="guid">
<div class="row">
<div class="col-sm-offset-2 col-sm-8">
{{if(!person)}}
{{if !person}}
<h3>New Person</h3>
{{else}}
<h3>Edit Person</h3>
Expand Down Expand Up @@ -55,9 +55,9 @@
<label for="devices" class="col-sm-2 control-label">Devices</label>
<div class="col-sm-4">
<select name="devices" multiple class="form-control">
{{loop(devices) as device}}
<option value="{{:device.DeviceName}}" {{if(device.Selected)}}selected{{endif}}>{{:device.DeviceName}}</option>
{{endloop}}
{{for device in devices}}
<option value="{{:device.DeviceName}}" {{if device.Selected}}selected{{endif}}>{{:device.DeviceName}}</option>
{{endfor}}
</select>
<span style="font-size: 80%">(Ctrl+Click to select multiple devices)</span>
</div>
Expand All @@ -70,7 +70,7 @@
</div>
<div class="col-sm-2">

{{if(person)}}
{{if person}}
<button type="button" onclick="doDelete()" class="btn btn-primary btn-block">Delete</button>
{{else}}
<button type="submit" class="btn btn-primary btn-block">Save</button>
Expand All @@ -80,4 +80,4 @@
</form>
</div>
</div>
{{include("partials/footer.tpro")}}
{{include "partials/footer.tpro"}}
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
{{loop(people) as person}}{{:person.guid}};"{{:person.FirstName}}";"{{:person.LastName}}";{{:person.Age}}
{{endloop}}
{{for person in people}}{{:person.guid}};"{{:person.FirstName}}";"{{:person.LastName}}";{{:person.Age}}
{{endfor}}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{{include("partials/header.tpro")}}
{{include "partials/header.tpro" }}
<div class="row_fluid">
<div class="col-sm-12">
<table class="table table-striped">
Expand All @@ -12,18 +12,18 @@
</tr>
</thead>
<tbody>
{{if(people)}}
{{loop(people) as person}}
{{if people}}
{{for person in people}}
<tr>
<td>{{:person.@@index}}</td>
<td>{{:person.FirstName}}</td>
<td>{{:person.LastName}}</td>
<td>{{:person.Age}}</td>
<td class="text-right">
{{include("view_person_link.tpro")}}
{{include "view_person_link.tpro"}}
</td>
</tr>
{{endloop}}
{{endfor}}
{{else}}
<tr>
<td class="text-center" colspan="5">&lt;&lt;No People Found&gt;&gt;</td>
Expand All @@ -42,4 +42,4 @@
<a class="btn btn-primary btn-block" href="/new">Add New Person</a>
</div>
</div>
{{include("partials/footer.tpro")}}
{{include "partials/footer.tpro"}}
26 changes: 13 additions & 13 deletions samples/serversideviews_templatepro/bin/templates/showcase.tpro
Original file line number Diff line number Diff line change
Expand Up @@ -37,25 +37,25 @@ This page is a showcase for all the TemplatePro features usable from DMVCFramewo
<div>
<h2 class="section">List of objects</h2>
<div>
{{if(people)}}
{{if people}}
<div>No People Found</div>
{{else}}
{{loop(people) as person}}
{{for person in people}}
<div>{{:person.@@index}}. {{:person.FirstName}} {{:person.LastName}}</div>
{{endloop}}
{{endfor}}
{{endif}}
</div>
</div>

<div>
<h2 class="section">Handle empty list of objects</h2>
<div>
{{if(!people2)}}
{{if !people2}}
<div>No People Found</div>
{{else}}
{{loop(people2) as person}}
{{for person in people2}}
<div>{{:person.@@index}}. {{:person.FirstName}} {{:person.LastName}}</div>
{{endloop}}
{{endfor}}
{{endif}}
</div>
</div>
Expand All @@ -75,9 +75,9 @@ This page is a showcase for all the TemplatePro features usable from DMVCFramewo
<div>
<h2><pre>Using include("partial_person.tpro")</pre></h2>
<ul>
{{loop(people) as person}}
<li>{{include("partial_person.tpro")}}</li>
{{endloop}}
{{for person in people}}
<li>{{include "partial_person.tpro"}}</li>
{{endfor}}
</ul>
</div>
</div>
Expand All @@ -90,9 +90,9 @@ This page is a showcase for all the TemplatePro features usable from DMVCFramewo
<li>Helpers cannot be nested (yet)</li>
</ul>
<div>
{{loop(people) as person}}
{{for person in people}}
<div>{{:person.@@index}}. {{:person.FirstName|uppercase}} {{:person.FirstName|uppercase}}</div>
{{endloop}}
{{endfor}}
</div>
<hr>
<h3>TemplatePro provides the following built-in helpers</h3>
Expand All @@ -109,9 +109,9 @@ This page is a showcase for all the TemplatePro features usable from DMVCFramewo
<p>json</p>
<p>
<h3>Serialize an iterator to json</h3>
{{loop(people) as person1}}
{{for person1 in people}}
<pre>{{:person1|json}}</pre>
{{endloop}}
{{endfor}}

<h3>Serialize a list of objects to json</h3>
{{:people|json}}
Expand Down
Loading

0 comments on commit b289b2f

Please sign in to comment.