コード例 #1
0
        public void Output_Of_String()
        {
            var sw  = new StringWriter(new StringBuilder());
            var two = new TextWriterOutput(sw);

            two.Write("text", null);
            sw.Flush();
            Assert.AreEqual("text", sw.ToString());
        }
コード例 #2
0
ファイル: Template.cs プロジェクト: yzbai/scriban
        public string ToText(ScriptPrinterOptions options = default(ScriptPrinterOptions))
        {
            CheckErrors();
            var writer        = new TextWriterOutput();
            var renderContext = new ScriptPrinter(writer, options);

            renderContext.Write(Page);

            return(writer.ToString());
        }
コード例 #3
0
ファイル: Template.cs プロジェクト: lizoc/textscript
        /// <summary>
        /// Converts back this template to a textual representation. This is the inverse of <see cref="Parse"/>.
        /// </summary>
        /// <param name="options">The rendering options</param>
        /// <returns>The template converted back to a textual representation of the template</returns>
        public string ToText(TemplateRewriterOptions options = default(TemplateRewriterOptions))
        {
            CheckErrors();
            TextWriterOutput        writer        = new TextWriterOutput();
            TemplateRewriterContext renderContext = new TemplateRewriterContext(writer, options);

            renderContext.Write(Page);

            return(writer.ToString());
        }
コード例 #4
0
        public void Output_Of_ValueStringBuilder()
        {
            using var sb = SmartFormat.Utilities.ZStringBuilderExtensions.CreateZStringBuilder();
            sb.Append("text");
            var sw  = new StringWriter(new StringBuilder());
            var two = new TextWriterOutput(sw);

            two.Write(sb, null);
            sw.Flush();
            Assert.AreEqual("text", sw.ToString());
        }
コード例 #5
0
        /// <summary> Writes out a formatted string, using the same semantics as Smart.Format. </summary>
        /// <param name="writer">The TextWriter that will be used for output</param>
        /// <param name="format">The template that defines how the arguments are formatted</param>
        /// <param name="args">A list of arguments to be used in formatting</param>
        public static void WriteSmart(this TextWriter writer, string format, params object[] args)
        {
            var output = new TextWriterOutput(writer);

            Smart.Default.FormatInto(output, format, args);
        }