internal static void GenerateOneSourceFile(HxlCompilerSession session, HxlTemplate template, TextWriter outputWriter) { // TODO Soft check here instead of casting IHxlEmittableTemplate t = (IHxlEmittableTemplate)template; t.GenerateSource(session, outputWriter); }
internal static void NameOrDefault(HxlTemplate template, out string name, out string type) { var builder = template as IHxlTemplateBuilder; NameOrDefault(template.GetType(), out name, out type); if (builder != null && !string.IsNullOrEmpty(builder.TemplateName)) { name = builder.TemplateName; } }
internal static HxlTemplateContext WithData(HxlTemplate owner, IEnumerable <KeyValuePair <string, object> > variables) { var tc = new HxlTemplateContext(owner); if (variables != null) { foreach (var e in variables) { tc.Data.Add(e.Key, e.Value); } } return(tc); }
public HxlTemplate CreateTemplate(string templateName, string templateType, IServiceProvider serviceProvider) { if (templateName == null) { throw new ArgumentNullException("templateName"); } if (string.IsNullOrEmpty(templateName)) { throw Failure.EmptyString("templateName"); } var info = RequireMap().FindTemplate(templateName, templateType); HxlTemplate result = null; Type type = null; if (info != null) { type = info.CompiledType; try { result = (HxlTemplate)Activator.CreateInstance(type); } catch (Exception ex) { Traceables.ReflectedTemplateFactoryCreateTemplateError( assembly, type, templateName, ex); throw; } } Traceables.ReflectedTemplateFactoryCreateTemplate( assembly, type, templateName, result != null); return(result); }
public static void Render(string inputFile, string outputFile, IEnumerable <KeyValuePair <string, object> > variables = null) { HxlTemplate template = HxlTemplate.FromFile(inputFile); template.Transform(outputFile, variables); }
public static string RenderText(string inputFile, IEnumerable <KeyValuePair <string, object> > variables = null) { HxlTemplate template = HxlTemplate.FromFile(inputFile); return(template.TransformText(variables)); }
public static bool TryParse(string text, out HxlTemplate result) { result = Parse(text); return(true); }