Created
March 30, 2015 22:35
-
-
Save rexm/e1a045b9f76a48de642e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var basicTestTemplate = "{{mycustomhelper Person.Address.City}}"; | |
var blockTestTemplate = "{{#mycustomblock Person.FirstName}} Hello world {{/mycustomblock}}"; | |
Handlebars.Handlebars.RegisterHelper ( | |
"mycustomhelper", | |
(writer, context, arguments) => writer.Write (arguments [0])); | |
Handlebars.Handlebars.RegisterHelper ( | |
"mycustomblock", (writer, options, context, arguments) => { | |
options.Template(writer, (object)context); | |
writer.Write(arguments[0]); | |
}); | |
var data = new { | |
Person = new { | |
FirstName = "Bob", | |
Address = new { | |
City = "New York" | |
} | |
} | |
}; | |
var basicTest = Handlebars.Handlebars.Compile (basicTestTemplate); | |
var blockTest = Handlebars.Handlebars.Compile (blockTestTemplate); | |
Console.WriteLine (basicTest (data)); | |
Console.WriteLine (blockTest (data)); | |
Console.Read (); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment