Example #1
0
        /// <summary>
        /// Renders a single page using the input asset and a layout.
        /// </summary>
        /// <param name="input">The input file to render.</param>
        /// <param name="layout">The layout to use for the render.</param>
        /// <returns>The content generated.</returns>
        public AssetContent RenderPage(IAssetFile input, string layout)
        {
            // Create the template with the specified layout
            var headers = input.Meta;
            var content =
                this.GetUsings() + Environment.NewLine +
                "@{Layout=\"" + layout + "\";}" + Environment.NewLine +
                input.Content.AsString();

            // Using a new scope, avoiding state sharing problems that way
            using (var service = new TemplateService())
            {
                // Process the content
                this.ProcessContent(content, service, headers);

                // Parse without caching
                return(AssetContent.FromString(
                           service.Parse(content, headers, null, null)
                           ));
            }
        }