Beispiel #1
0
        /// <summary>
        /// Renders a named partial template if one exists with the given context
        /// </summary>
        /// <param name="writer">The writer to write the token to</param>
        /// <param name="context">The context to discover values from</param>
        /// <param name="partials">The partial templates available to the token</param>
        /// <param name="originalTemplate">The original template</param>
        /// <returns>The rendered partial template</returns>
        public string Render(Writer writer, Context context, IDictionary<string, string> partials, string originalTemplate)
        {
            var value = partials != null && partials.ContainsKey(Value) ? partials[Value] : null;
            if (value == null && context.Registry.PartialTemplateLoader != null)
            {
                value = context.Registry.PartialTemplateLoader.Load(Value);
            }

            return value != null ? writer.RenderTokens(writer.Parse(value), context, partials, value) : null;
        }