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.139 tracks/csharp/generators/Output/TemplateRenderer.cs
trackler-2.2.1.138 tracks/csharp/generators/Output/TemplateRenderer.cs
trackler-2.2.1.137 tracks/csharp/generators/Output/TemplateRenderer.cs
trackler-2.2.1.136 tracks/csharp/generators/Output/TemplateRenderer.cs
trackler-2.2.1.135 tracks/csharp/generators/Output/TemplateRenderer.cs
trackler-2.2.1.134 tracks/csharp/generators/Output/TemplateRenderer.cs
trackler-2.2.1.133 tracks/csharp/generators/Output/TemplateRenderer.cs
trackler-2.2.1.132 tracks/csharp/generators/Output/TemplateRenderer.cs
trackler-2.2.1.131 tracks/csharp/generators/Output/TemplateRenderer.cs
trackler-2.2.1.130 tracks/csharp/generators/Output/TemplateRenderer.cs
trackler-2.2.1.129 tracks/csharp/generators/Output/TemplateRenderer.cs
trackler-2.2.1.128 tracks/csharp/generators/Output/TemplateRenderer.cs
trackler-2.2.1.127 tracks/csharp/generators/Output/TemplateRenderer.cs
trackler-2.2.1.126 tracks/csharp/generators/Output/TemplateRenderer.cs
trackler-2.2.1.125 tracks/csharp/generators/Output/TemplateRenderer.cs
trackler-2.2.1.124 tracks/csharp/generators/Output/TemplateRenderer.cs
trackler-2.2.1.123 tracks/csharp/generators/Output/TemplateRenderer.cs
trackler-2.2.1.122 tracks/csharp/generators/Output/TemplateRenderer.cs
trackler-2.2.1.121 tracks/csharp/generators/Output/TemplateRenderer.cs
trackler-2.2.1.120 tracks/csharp/generators/Output/TemplateRenderer.cs