예제 #1
0
 public string Render(string name, string template, string json)
 {
     if (string.IsNullOrEmpty(json))
     {
         json = "{}";
     }
     return((string)_context.Evaluate("Handlebars.compile('" + HandlebarsUtilities.ToJavaScriptString(template) + "')(" + json + ");"));
 }
예제 #2
0
 public void Compile(string name, string template)
 {
     template = HandlebarsUtilities.ToJavaScriptString(template);
     _context.Execute("raw['" + name + "'] = '" + template + "';\n" +
                      "Handlebars.templates['" + name + "'] = Handlebars.compile('" + template + "');");
 }
예제 #3
0
        public string Render(string name, string template, object context)
        {
            string json = context is string?(string)context : HandlebarsUtilities.ToJson(context);

            return(Render(name, template, json));
        }
예제 #4
0
        public string Render(string name, object context)
        {
            var json = context is string?(string)context : HandlebarsUtilities.ToJson(context);

            return((string)_context.Evaluate("Handlebars.templates['" + name + "'](" + json + ");"));
        }
예제 #5
0
 public void PartialCompile(string name, string template)
 {
     template = HandlebarsUtilities.ToJavaScriptString(template);
     _context.Execute("raw['" + name + "'] = '" + template + "';\n" +
                      "Handlebars.registerPartial('" + name + "','" + template + "');");
 }
예제 #6
0
 public string Render(string name, string template, object context)
 {
     return(Render(name, template, HandlebarsUtilities.ToJson(context)));
 }