Esempio n. 1
0
        /// <summary>
        /// Includes the template with the specified name.
        /// </summary>
        /// <param name="cacheName">The name of the template type in cache.</param>
        /// <param name="model">The model or NULL if there is no model for the template.</param>
        /// <returns>The template writer helper.</returns>
        public virtual TemplateWriter Include(string cacheName, object model = null)
        {
            var instance = TemplateService.Resolve(cacheName, model);

            if (instance == null)
            {
                throw new ArgumentException("No template could be resolved with name '" + cacheName + "'");
            }

            return(new TemplateWriter(tw =>
                                      tw.Write(instance.Run(
                                                   TemplateService.CreateExecuteContext(ViewBag)))));
        }
Esempio n. 2
0
 /// <summary>
 /// Resolves the layout template.
 /// </summary>
 /// <param name="name">The name of the layout template.</param>
 /// <returns>An instance of <see cref="ITemplate"/>.</returns>
 protected override ITemplate ResolveLayout(string name)
 {
     return(TemplateService.Resolve(name, (T)currentModel));
 }
Esempio n. 3
0
 /// <summary>
 /// Resolves the layout template.
 /// </summary>
 /// <param name="name">The name of the layout template.</param>
 /// <returns>An instance of <see cref="ITemplate"/>.</returns>
 protected virtual ITemplate ResolveLayout(string name)
 {
     return(TemplateService.Resolve(name, null));
 }