예제 #1
0
        /// <summary>
        /// Parse a template and return a <see cref="MustacheTemplate"/>
        /// </summary>
        /// <param name="text">The text to be parsed</param>
        /// <param name="startingTags">The starting tag description</param>
        /// <param name="lineIndent">The default line indent for the template</param>
        /// <param name="pipeline">The pipeline to use for parsing</param>
        /// <returns>The string converted to Tags</returns>
        public static MustacheTemplate Parse(string text, Classes.Tags startingTags = null, int lineIndent = 0, ParserPipeline pipeline = null)
        {
            if (text == null)
            {
                throw new ArgumentNullException(nameof(text));
            }

            startingTags = startingTags ?? new Classes.Tags("{{", "}}");
            pipeline     = pipeline ?? new ParserPipelineBuilder().Build();

            var mustacheParser = new MustacheParser(text, startingTags, lineIndent, pipeline);

            return(mustacheParser.Parse());
        }
예제 #2
0
        /// <inheritdoc/>
        public MustacheTemplate Parse(string text, Tags startingTags = null, int lineIndent = 0, ParserPipeline pipeline = null)
        {
            if (text == null)
            {
                throw new ArgumentNullException(nameof(text));
            }

            var key     = new TemplateKey(text, startingTags, lineIndent);
            var success = Cache.TryGetValue(key, out MustacheTemplate template);

            if (!success)
            {
                template = Cache[key] = MustacheParser.Parse(text, startingTags, lineIndent, pipeline);
            }

            return(template);
        }
예제 #3
0
 /// <inheritdoc/>
 public MustacheTemplate Parse(string text, Classes.Tags startingTags = null, int lineIndent = 0, ParserPipeline pipeline = null)
 {
     return(MustacheParser.Parse(text, startingTags, lineIndent, pipeline));
 }