コード例 #1
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());
        }
コード例 #2
0
ファイル: ScriptPrinter.cs プロジェクト: yzbai/scriban
        public ScriptPrinter(IScriptOutput output, ScriptPrinterOptions options = default(ScriptPrinterOptions))
        {
            _isWhileLoop = new FastStack <bool>(4);
            Options      = options;
            if (options.Mode != ScriptMode.Default && options.Mode != ScriptMode.ScriptOnly)
            {
                throw new ArgumentException($"The rendering mode `{options.Mode}` is not supported. Only `ScriptMode.Default` or `ScriptMode.ScriptOnly` are currently supported");
            }

            _isScriptOnly      = options.Mode == ScriptMode.ScriptOnly;
            _isInCode          = _isScriptOnly || (options.Mode == ScriptMode.FrontMatterOnly || options.Mode == ScriptMode.FrontMatterAndContent);
            _output            = output;
            _hasEndOfStatement = true; // We start as if we were on a new line
        }