Complex JS Render / JS Views Testing
by blowsie
HTML
<script src="http://borismoore.github.com/jsviews/jsrender.js"></script>
<script src="http://borismoore.github.com/jsviews/jquery.observable.js"></script>
<script src="http://borismoore.github.com/jsviews/jquery.views.js"></script>
<script id="viewFormTemplate" type="text/x-jquery-tmpl">
<div class="form" id="{{=Id}}">
<h1>{{=FormTitle}}</h1>
{{#each SubForms}}
{{#each SubForm}}
<div class="subform">
<h2>{{=SubFormTitle}}</h2>
{{#each Groups}}
{{#each Group tmpl="#viewGroupTemplate"}}
{{/each}}
{{/each}}
</div>
{{/each}}
{{/each}}
</div>
</script>
<script id="viewGroupTemplate" type="text/x-jquery-tmpl">
{{#if RenderasTable == "true"}}
{{#if PivotFields == "true" tmpl="#viewPivotTableTemplate"}}
{{else tmpl="#viewTableTemplate"}}
{{/if}}
{{else}}
<div class="group">
<h3>{{=GroupTitle}}</h3>
{{#each Fields}}
{{#each Field}}
<div class="field">
<p> {{=MetaValue}} </p>
</div>
{{/each}}
{{/each}}
</div>
{{/if}}
</script>
<script id="viewPivotTableTemplate" type="text/x-jquery-tmpl">
{{#if $ctx.checkGroups($view)}}
{{/if}}
{{#if groupGroups == "true"}}
<tr class="group">
{{#each Fields}}
{{#each Field}}
...
JavaScript
var data = {
projectform: {
id: '3c9bccbb-840e-4ea8-b35a-376e8e263337',
version: 5,
templateformid: '118e553d-bc7f-4ce1-b280-4ed7cc71a1e6',
subforms: {
subform: {
subformtitle: 'Schedule',
canduplicate: 'false',
groups: {
group: [
{
fieldssortable: 'false',
locked: 'false',
pivotfields: 'false',
renderastable: 'true',
grouptitle: 'Details',
issummary: 'false',
canduplicate: 'false',
fields: {
field: [
{
title: 'Asset Ref',
fieldtype: '95a3afcc-38c8-4175-9f8a-1a9e0e3274d4',
fieldtyperender: 1,
metavalue: 'TANKS 1, 2, 3, 5 and 6 From XML'},
{
title: 'Location',
fieldtype: '2c19dfd6-8734-4eb8-b92c-70f9423c1775',
fieldtyperender: 1,
metavalue: 'ROOF TANK ROOMS '},
{
title: 'Model',
fieldtype: '2b28ca28-0a16-4852-acc6-e5cf1a4b5140',
fieldtyperender: 1,
metavalue: 'RELINING OF TANKS '},
{
title: 'Item Type',
fieldtype: '410942fb-f4c3-48d2-9ec8-5b26103382f9',
fieldtyperender: 5,
metavalue: 'a1b7e7b2-9b3e-dd11-8804-000bdbd51a6c'},
{
title:...