public string ReplacePlaceholders()
        {
            var source = File.ReadAllText(TemplatePath);

            ParameterAccessor.ToList().ForEach(pair => { source = source.Replace($"##{pair.Key}##", pair.Value(Parameter)); });
            PartialMap.ToList().ForEach(pair => { source = source.Replace($"##{pair.Key}##", pair.Value); });
            source = Regex.Replace(source, "##[^#]+##", string.Empty);
            return(source);
        }
示例#2
0
        /// <summary>
        /// Gets the partials from the given template content
        /// </summary>
        /// <param name="content">The template content</param>
        /// <param name="id">The template Id</param>
        /// <param name="alias">The template Alias</param>
        /// <returns>Any partials in the template</returns>
        internal static IEnumerable <PartialMap> GetPartialInfo(string content, int id, string alias)
        {
            MatchCollection   matches  = HtmlPartialRegex.Matches(content);
            List <PartialMap> partials = new List <PartialMap>();

            foreach (Match match in matches)
            {
                if (match.Success)
                {
                    PartialMap partial = new PartialMap();
                    partial.TemplateId    = id;
                    partial.TemplateAlias = alias;
                    partial.Name          = match.Groups[2].Value;
                    partial.IsCached      = match.Groups[1].Value == "Cached";
                    partial.Path          = partial.Name.Replace("/", "%252F") + ".cshtml";
                    partials.Add(partial);
                }
            }

            return(partials);
        }
示例#3
0
        /// <summary>
        /// Gets the partials from the given template content
        /// </summary>
        /// <param name="content">The template content</param>
        /// <param name="id">The template Id</param>
        /// <param name="alias">The template Alias</param>
        /// <returns>Any partials in the template</returns>
        internal static IEnumerable <PartialMap> GetPartialInfo(string content, int id, string alias)
        {
            MatchCollection matches  = HtmlPartialRegex.Matches(content);
            var             partials = new List <PartialMap>();

            foreach (Match match in matches)
            {
                if (match.Success)
                {
                    var partial = new PartialMap
                    {
                        TemplateId    = id,
                        TemplateAlias = alias,
                        Name          = match.Groups[2].Value,
                        IsCached      = match.Groups[1].Value == "Cached"
                    };

                    partial.Path = partial.Name.Replace("/", "%252F").Replace("~%252FViews%252FPartials%252F", string.Empty);
                    partials.Add(partial);
                }
            }

            return(partials);
        }