public string Template()
        {
            using var writer            = ReusableStringWriter.Get();
            using var encodedTextWriter = new EncodedTextWriter(writer, Frame.Configuration.TextEncoder, FormatterProvider.Current);

            OriginalTemplate(encodedTextWriter, Frame);

            return(encodedTextWriter.ToString());
        }
Example #2
0
        public HandlebarsTemplate <object, object> CompileView(string templatePath)
        {
            var view = CompileViewInternal(templatePath, ViewReaderFactory);

            return((vm, data) =>
            {
                var formatProvider = Configuration?.FormatProvider ?? CompiledConfiguration.FormatProvider;
                using var writer = ReusableStringWriter.Get(formatProvider);
                view(writer, vm, data);
                return writer.ToString();
            });
        }
Example #3
0
        public HandlebarsTemplate <object, object> Compile(string template)
        {
            using var reader = new StringReader(template);
            var compiledTemplate = Compile(reader);

            return((context, data) =>
            {
                var formatProvider = Configuration?.FormatProvider ?? CompiledConfiguration?.FormatProvider;
                using var writer = ReusableStringWriter.Get(formatProvider);
                compiledTemplate(writer, context, data);
                return writer.ToString();
            });
        }
Example #4
0
 public Func <object, string> Compile(string template)
 {
     using (var reader = new StringReader(template))
     {
         var compiledTemplate = Compile(reader);
         return(context =>
         {
             var formatProvider = Configuration?.FormatProvider ?? CompiledConfiguration?.FormatProvider;
             using var writer = ReusableStringWriter.Get(formatProvider);
             compiledTemplate(writer, context);
             return writer.ToString();
         });
     }
 }
Example #5
0
 public string Format(T item)
 {
     using var writer = ReusableStringWriter.Get();
     _formatter(item, _state, writer);
     return(writer.ToString());
 }
 public static object This(this HelperOptions options, object context, Func <HelperOptions, Action <TextWriter, object> > selector)
 {
     using var writer = ReusableStringWriter.Get(options.Configuration.FormatProvider);
     selector(options)(writer, context);
     return(writer.ToString());
 }