|
{block} With the <b>{data}</b> tag it is possible to define data for later use. {/block}
{page 'data/1'}
<hr>
{block} Data can be in xml/json/yaml/csv format. <br><br> There is also an own PAD list format with opening ( and closing )</p> {/block}
{page 'data/2'}
<hr>
{block} <p> If <b>{data 'xxx'}</b> is used, then the data will not be processed before it is stored in the data store,<br>all above examples use it in this way.</p> <p>If <b>{/data 'xxx'}</b> is used, then the data will be processed before it is stored in the data store.<br> Below a crazy example how this can be used: <br> - first there is a JSON data definition<br> - then this JSON data is converted to CSV data<br> - then this CSV data is converted to XML data<br> - then this XML data is converted to YAML data<br> - then this YAML data is used to show a HTML table. {/block}
{page 'data/3'}
|
|
With the {data} tag it is possible to define data for later use.
|
| HTML |
RESULT |
{data 'myData'} [ { "name": "joe", "phone": "555-3425" }, { "name": "jim", "phone": "555-2364" }, { "name": "jack", "phone": "555-3422" }, { "name": "jerry", "phone": "555-4973" } ] {/data}
<table border="1"> {myData} <tr> <td>{$name}</td> <td>{$phone}</td> </tr> {/myData} </table>
|
| joe |
555-3425 |
| jim |
555-2364 |
| jack |
555-3422 |
| jerry |
555-4973 |
|
Data can be in xml/json/yaml/csv format.
There is also an own PAD list format with opening ( and closing )
|
| HTML |
RESULT |
{data 'myXML'} <data> <row name="bob" phone="555-1111" /> <row name="jim" phone="555-2222" /> <row name="joe" phone="555-3333" /> <row name="jerry" phone="555-4444" /> </data> {/data}
{data 'myJSON'} [ { "name": "bob", "phone": "555-5555" }, { "name": "jim", "phone": "555-6666" }, { "name": "joe", "phone": "555-7777" }, { "name": "jerry", "phone": "555-8888" } ] {/data}
{data 'myYAML'} --- - name: bob phone: 555-3425 - name: jim phone: 555-4364 - name: joe phone: 555-3422 - name: jerry phone: 555-4973 {/data}
{data 'myCSV'} name,phone bob,555-3425 jim,555-4364 joe,555-3422 jerry,555-4973 {/data}
{data 'myList'} ( 'myXML', 'myJSON', 'myYAML', 'myCSV' ) {/data}
| | {myList} <p> <table border=1> <tr> <th colspan="2"> {$myList} </th> </tr> {pad data='{$myList}'} <tr> <td>{$name}</td> <td>{$phone}</td> </tr> {/pad} </table> </p> {/myList}
|
|
myXML
|
| bob |
555-1111 |
| jim |
555-2222 |
| joe |
555-3333 |
| jerry |
555-4444 |
|
myJSON
|
| bob |
555-5555 |
| jim |
555-6666 |
| joe |
555-7777 |
| jerry |
555-8888 |
|
myYAML
|
| bob |
555-3425 |
| jim |
555-4364 |
| joe |
555-3422 |
| jerry |
555-4973 |
|
myCSV
|
| bob |
555-3425 |
| jim |
555-4364 |
| joe |
555-3422 |
| jerry |
555-4973 |
|
|
If {data 'xxx'} is used, then the data will not be processed before it is stored in the data store, all above examples use it in this way.
If {/data 'xxx'} is used, then the data will be processed before it is stored in the data store. Below a crazy example how this can be used:
- first there is a JSON data definition
- then this JSON data is converted to CSV data
- then this CSV data is converted to XML data
- then this XML data is converted to YAML data
- then this YAML data is used to show a HTML table.
|
| HTML |
RESULT |
{data 'myJson'} [ { "name": "bob", "phone": "555-5555" }, { "name": "jim", "phone": "555-6666" }, { "name": "joe", "phone": "555-7777" }, { "name": "jerry", "phone": "555-8888" } ] {/data}
{data} name,phone {myJson} {$name}, {$phone} {/myJson} {/data 'myCsv'}
{data} <records> {myCsv} <record name="{$name}" phone="{$phone}"/> {/myCsv} </records> {/data 'myXml'}
{data} --- {myXml} - name: {$name} phone: {$phone} {/myXml} {/data 'myYaml'}
| | <table border="1"> {myYaml} <tr> <td>{$name}</td> <td>{$phone}</td> </tr> {/myYaml} </table>
|
| bob |
555-5555 |
| jim |
555-6666 |
| joe |
555-7777 |
| jerry |
555-8888 |
|
|