parse the mustache content

89 views
Skip to first unread message

Vikas Rajoria

unread,
Dec 26, 2016, 5:39:16 AM12/26/16
to mustache.java
Hi I am newbee with handlebars. I looking for a way i can parse html template with mustache code and generate JSON payload from the mustache variable/sections/lambdas used in the template. 
for ex if i  have my template as:

<html>
<head>
<body>
<table id="a" class="b">
<tr>
<td>
Hi {{customer.firstName}} {{customer.lastName}}
</td>
</tr>
<tr>
<td>
{{#if order.[0].gOrder}}
Grocery order {{order.[0].gOrder.orderId}}
{{/if}}
</td>
</tr>
</body>
</head>
</html>

i should get json for above as :

{
"customer": {
"firstName": "",
"lastName": ""
},
"order": {
"0": {
"gOrder": []
}
}
}

Any help is appreciated!

Sam

unread,
Jan 17, 2017, 3:47:26 PM1/17/17
to mustache.java
I think that this could be possible with the CapturingJsonVisitor in mustache but with handlebars it would be tougher because of the more complicated references in the code.

Sam
Reply all
Reply to author
Forward
0 new messages