private static string Format(Template script, ScriptFormatterFlags flags) { var newScript = script.Page.Format(new ScriptFormatterOptions(flags)); var result = newScript.ToString(); return(result); }
public ScriptFormatter(ScriptFormatterOptions options) { Options = options; _flags = options.Flags; CopyTrivias = !_flags.HasFlags(ScriptFormatterFlags.RemoveExistingTrivias); _isScientific = options.Language == ScriptLang.Scientific; _context = options.Context == null && _isScientific ? throw new InvalidOperationException("The context within the options cannot be null when the scientific language is used.") : options.Context; _compressWhitespacesVisitor = _flags.HasFlags(ScriptFormatterFlags.CompressSpaces) ? new CompressWhitespacesVisitor() : null; }
public ScriptFormatterOptions(TemplateContext context, ScriptLang language, ScriptFormatterFlags flags) { Language = language; Flags = flags; Context = context == null && language == ScriptLang.Scientific ? throw new ArgumentNullException(nameof(context), "Context cannot be null with scientific language.") : context; }
public ScriptFormatterOptions(ScriptFormatterFlags flags) { Language = ScriptLang.Default; Flags = flags; Context = null; }
public static bool HasFlags(this ScriptFormatterFlags input, ScriptFormatterFlags flags) => (input & flags) == flags;