load string.template var source = @[]

By {{author.firstName}} {{author.lastName}}

{{body}}

Comments

{{! This is a comment}} {{#not_empty comments}}

Number of comments: {{@count}}

{{#each comments}}

{{@index}}/{{@count}}. By {{author.firstName}} {{author.lastName}}

{{#each author}} {{@key}} {{@value}} {{/each}}
{{body}}
{{/each}} {{/contain}}
@[] var context = { "author" => {"firstName" => "Alan", "lastName" => "Johnson"}, "body" => "I Love Handlebars", "comments" => { { "author" => {"firstName" => "Yehuda", "lastName" => "Katz"}, "body" => "Me too!" }, { "author" => {"firstName" => "Yehuda2", "lastName" => "Katz2"}, "body" => "Me too!" }, { "author" => {"firstName" => "Yehuda2", "lastName" => "Katz2"}, "body" => "Me too!" } } }; var context2 = ( author = (firstName = "Alan", lastName = "Johnson"), body = "I Love Handlebars", comments = { ( author = (firstName = "Yehuda", lastName = "Katz"), body = "Me too!" ), ( author = (firstName = "Yehuda2", lastName = "Katz2"), body = "Me too!" ), ( author = (firstName = "Yehuda2", lastName = "Katz2"), body = "Me too!" ) } ); io.writeln( str::template( source, context ) ) io.writeln( str::template( source, context2 ) )