__collection
special propertyThere is a special property __collection
of each child property of Data
object. Using this property you can navigate through collection of child properties of current property.
Let's assume that you have the following folder structure on your file system:
Data
Poland.json
Ukraine.json
And inside each .json
file in this example you have the following structure:
{
"details": {
"flag": "flag.png",
"date": "1st of February",
"address": "Main street"
}
}
And your template may look like this:
<ul>
{{# Data.__collection }}
<li>
<img src="{{ flag }}"/>
On {{ date }} at {{ address }}
</li>
{{/ Data.__collection }}
</ul>
Finally, the html rendered by Solidify Engine will look like this:
<ul>
<li>
<img src="poland.png"/>
On 1st of February in Warsaw
</li>
<li>
<img src="ukraine.png"/>
On 1st of March in Kyiv
</li>
</ul>
You can also use nested __collection
properties.
Let's assume that you have the following folder structure on you file system:
Data
year1999
Poland.json
Ukraine.json
year2001
Bulgaria.json
Romania.json
year2020
Denmark.json
Spain.json
And inside each .json
file in this example you have the following structure:
{
"details": {
"flag": "flag.png",
"date": "1st of February",
"address": "Main street"
}
}
And your template may look like this:
<ul>
{{# Data.__collection }}
{{# __collection }}
<li>
<img src="{{ flag }}"/>
On {{ date }} at {{ address }}
</li>
{{/ __collection }}
{{/ Data.__collection }}
</ul>
Finally, the html rendered by Solidify Engine will look like this:
<ul>
<li>
<img src="poland.png"/>
On 1st of February in Warsaw
</li>
<li>
<img src="ukraine.png"/>
On 1st of March in Kyiv
</li>
<li>
<img src="bulgaria.png"/>
On 1st of April in Sofia
</li>
<li>
<img src="romania.png"/>
On 1st of May in Bucharest
</li>
<li>
<img src="denmark.png"/>
On 1st of June in Copenhagen
</li>
<li>
<img src="spain.png"/>
On 1st of July in Madrid
</li>
</ul>
__names
special propertyThere is a special property __names
of each child property of Data
object. Using this property you can navigate through names of child properties of current property.
Let's assume that you have the following folders structure on you file system:
Data
Poland.json
Ukraine.json
And inside each .json
file in this example you have the following structure:
{
"details": {
"flag": "flag.png",
"date": "1st of February",
"address": "Main street"
}
}
And your template may look like this:
<ul>
{{# Data.__names }}
<li>
{{ . }}
</li>
{{/ Data.__names }}
</ul>
Finally, the html rendered by Solidify Engine will look like this:
<ul>
<li>
Poland
</li>
<li>
Ukraine
</li>
</ul>
You can also use __names
together with nested __collection
properties.
Let's assume that you have the following folder structure on you file system:
Data
year1999
Poland.json
Ukraine.json
year2001
Bulgaria.json
Romania.json
year2020
Denmark.json
Spain.json
And inside each .json
file in this example you have the following structure:
{
"details": {
"flag": "flag.png",
"date": "1st of February",
"address": "Main street"
}
}
And your template may look like this:
<ul>
{{# Data.__collection }}
{{# __names }}
<li>
{{ . }}
</li>
{{/ __names }}
{{/ Data.__collection }}
</ul>
Finally, the html rendered by Solidify Engine will look like this:
<ul>
<li>
Poland
</li>
<li>
Ukraine
</li>
<li>
Bulgaria
</li>
<li>
Romania
</li>
<li>
Denmark
</li>
<li>
Spain
</li>
</ul>
Solidify Project is powered by .NET Core 2.0 and distributed under MIT license