Querying wb-hbs v0.1.0+alpha
Templating content with HandlebarsJS
Try the following URL:
- Empty
?
- Canada
?country=CA
- Belgique
?country=BG
- Canada, kiwi
?country=CA&fruits=kiwi
- Canada, kiwi, poire
?country=CA&fruits=kiwi&fruits=poire
- Canada, Belgique
?country=CA&country=BG
(wont work as "fruits") - Pierre est genial
?pierre=genial
- Bob
?bob
Read RFC6902 to know how to make JSON patch operation and RFC6901 to know how to locate the data in a JSON object.
My first template
Created by: {{firstName.cic}} {{lastName}}
Our country is: {{country}}
-
{{#each fruits}}
- Fruit: {{this}} {{/each}}
There is {{nbfruits}}
Jour is {{jour}}
<div class="wb-hbs" data-wb-hbs='{
"template": "#mytemplate",
"data": "data-2.json",
"mapping": {
"country" : "/",
"fruits" : {
"isPlainValue": true
},
"pierre=genial": [
{ "op": "replace", "path": "/firstName/cic", "value":"Pierre" },
{ "op": "replace", "path": "/lastName", "value":"Dubois" },
{ "op": "replace", "path": "/country", "value":"Québec" }
],
"bob": [
{ "op": "add", "path": "/fruits/0", "value":"Bob" }
]
}
}'></div>
<div class="hidden">
<div id="mytemplate">
<h1>My first template</h1>
<p>Created by: {{firstName.cic}} {{lastName}}</p>
<p>Our country is: <strong>{{country}}</strong></p>
<ul>
{{#each fruits}}
<li>Fruit: <em>{{this}}</em></li>
{{/each}}
</ul>
</div>
</div>
data-2.json
{
"@context": {
},
"firstName": {
"cic": "Toufic",
"ic": "Pierre"
},
"lastName": "Sbeiti",
"country": {
"CA": "Canada",
"BG": "Belgique"
},
"fruits": [
"pomme",
"banane",
"orange"
]
}
- Date modified: