Sha256: b35191e5e400e93efeb05e3399bc57198b95ca6900326df6137ae82ccf2051f1

Contents?: true

Size: 864 Bytes

Versions: 166

Compression:

Stored size: 864 Bytes

Contents

using System.Reflection;
using DotLiquid;
using DotLiquid.FileSystems;

namespace Generators.Output
{
    public static class TemplateRenderer
    {
        private static readonly string EmbeddedTemplatesNamespace = $"{typeof(TemplateRenderer).Namespace}.Templates";

        static TemplateRenderer()
        {
            Template.RegisterFilter(typeof(IndentFilter));
            Template.FileSystem = new EmbeddedFileSystem(Assembly.GetEntryAssembly(), EmbeddedTemplatesNamespace);
        }

        public static string RenderInline(string template, object parameters)
            => Template.Parse(template).Render(Hash.FromAnonymousObject(parameters));

        public static string RenderPartial(string template, object parameters) 
            => Template.Parse($"{{% include \"{template}\" %}}").Render(Hash.FromAnonymousObject(parameters));
    }
}

Version data entries

166 entries across 166 versions & 1 rubygems

Version Path
trackler-2.2.1.119 tracks/csharp/generators/Output/TemplateRenderer.cs
trackler-2.2.1.118 tracks/csharp/generators/Output/TemplateRenderer.cs
trackler-2.2.1.117 tracks/csharp/generators/Output/TemplateRenderer.cs
trackler-2.2.1.116 tracks/csharp/generators/Output/TemplateRenderer.cs
trackler-2.2.1.115 tracks/csharp/generators/Output/TemplateRenderer.cs
trackler-2.2.1.114 tracks/csharp/generators/Output/TemplateRenderer.cs
trackler-2.2.1.113 tracks/csharp/generators/Output/TemplateRenderer.cs
trackler-2.2.1.111 tracks/csharp/generators/Output/TemplateRenderer.cs
trackler-2.2.1.110 tracks/csharp/generators/Output/TemplateRenderer.cs
trackler-2.2.1.109 tracks/csharp/generators/Output/TemplateRenderer.cs
trackler-2.2.1.108 tracks/csharp/generators/Output/TemplateRenderer.cs
trackler-2.2.1.107 tracks/csharp/generators/Output/TemplateRenderer.cs
trackler-2.2.1.106 tracks/csharp/generators/Output/TemplateRenderer.cs
trackler-2.2.1.105 tracks/csharp/generators/Output/TemplateRenderer.cs
trackler-2.2.1.104 tracks/csharp/generators/Output/TemplateRenderer.cs
trackler-2.2.1.103 tracks/csharp/generators/Output/TemplateRenderer.cs
trackler-2.2.1.102 tracks/csharp/generators/Output/TemplateRenderer.cs
trackler-2.2.1.101 tracks/csharp/generators/Output/TemplateRenderer.cs
trackler-2.2.1.100 tracks/csharp/generators/Output/TemplateRenderer.cs
trackler-2.2.1.99 tracks/csharp/generators/Output/TemplateRenderer.cs