Xbasic
NodeServices::HandleBars::RunTemplate Method
Syntax
RunTemplate as c(template as c, data as c)
Arguments
- template
HandleBars template string.
- data
JSON data to be used to fill in the handle template.
Description
Use template against data
Example
dim hb as nodeservices::handlebars dim source as c = <<%str% #<p>Hello, my name is {{name}}. I am from {{hometown}}. I have #{{kids.length}} kids:</p> #<ul>{{#kids}}<li>{{name}} is {{age}}</li>{{/kids}}</ul> #%str% dim json as c = <<%str% #{ # "name": "Alan", # "hometown": "Somewhere, TX", # "kids": [{ "name": "Jimmy", "age": "12" }, { "name": "Sally", "age": "4" }] #} #%str% ? hb.RunTemplate(source,json) = <p>Hello, my name is Alan. I am from Somewhere, TX. I have 2 kids:</p> <ul><li>Jimmy is 12</li><li>Sally is 4</li></ul>
To learn more about Handelbars, visit the HandlbarsJS Website.
See Also