We are a little confused about pre-compiling a template. for example:
Is it possible to store the template variable in say a database and then just retrieve it and call
string source =
@"<div class=""entry"">
<h1>{{title}}</h1>
<div class=""body"">
{{body}}
</div>
</div>";
var storedTemplate = Handlebars.Compile(source);
Once we have the compiled template then store the variabe storedTemplate in a database. Then whenever we need it, just retreive from Database and pass the required object.
//retrieve template
var retrievedTemplate = retrieve storedTemplate from datase
var data = new {
title = "My new post",
body = "This is my first post!"
};
var result = retrievedTemplate (data);
But we cannot get this to work and wonder why.