/// <summary>
        /// Includes the template with the specified name.
        /// </summary>
        /// <param name="name">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>
        /// <param name="modelType"></param>
        /// <returns>The template writer helper.</returns>
        public virtual TemplateWriter Include(string name, object model = null, Type modelType = null)
        {
            var instance = InternalTemplateService.Resolve(name, model, modelType, (DynamicViewBag)ViewBag, ResolveType.Include);

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

            // TODO: make TemplateWriter async?
            return(new TemplateWriter(tw =>
                                      instance.Run(
                                          InternalTemplateService.CreateExecuteContext(), tw)
                                      .Wait()

                                      ));
        }
Exemple #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 virtual ITemplate ResolveLayout(string name)
 {
     return(InternalTemplateService.Resolve(name, null, null, (DynamicViewBag)ViewBag, ResolveType.Layout));
 }
Exemple #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 override ITemplate ResolveLayout(string name)
 {
     return(InternalTemplateService.Resolve(name, (T)currentModel, ModeType, (DynamicViewBag)ViewBag, ResolveType.Layout));
 }