예제 #1
0
        public Func <object, string> CompileView(string templatePath)
        {
            var configuration   = new InternalHandlebarsConfiguration(Configuration);
            var createdFeatures = configuration.Features;

            for (var index = 0; index < createdFeatures.Count; index++)
            {
                createdFeatures[index].OnCompiling(configuration);
            }

            var compiler                 = new HandlebarsCompiler(configuration);
            var compiledView             = compiler.CompileView(templatePath, configuration);
            Func <object, string> action = (vm) =>
            {
                using (var writer = new PolledStringWriter(configuration.FormatProvider))
                {
                    compiledView(writer, vm);
                    return(writer.ToString());
                }
            };

            for (var index = 0; index < createdFeatures.Count; index++)
            {
                createdFeatures[index].CompilationCompleted();
            }

            return(action);
        }
 public CollectionMemberAliasProvider(InternalHandlebarsConfiguration configuration)
 {
     _configuration = configuration;
 }