Querying wb-hbs v0.1.0+alpha

Templating content with HandlebarsJS

Try the following URL:

Read RFC6902 to know how to make JSON patch operation and RFC6901 to know how to locate the data in a JSON object.

<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: