public void Compose(ContentAreaRenderingContext context, TagBuilder tagBuilder) { foreach (var item in _registry) { item.Apply(context, tagBuilder); } }
public void Apply(ContentAreaRenderingContext context, TagBuilder tagBuilder) { if (ShouldApply(context, tagBuilder)) { ApplyCore(context, tagBuilder); } }
protected virtual void ApplyCore(ContentAreaRenderingContext context, TagBuilder tagBuilder, string viewDataKey) { var attributes = context.ViewData[viewDataKey]; if (attributes == null) { return; } tagBuilder.MergeAttributes(new RouteValueDictionary(attributes)); }
public virtual void Apply(ContentAreaRenderingContext context, TagBuilder tagBuilder) { if (context.IsRenderingContentArea()) { ApplyCore(context, tagBuilder, "customattributes"); } else if (context.IsRenderingContentAreaItem()) { ApplyCore(context, tagBuilder, "childrencustomattributes"); } }
protected abstract bool ShouldApply(ContentAreaRenderingContext context, TagBuilder tagBuilder);
protected abstract void ApplyCore(ContentAreaRenderingContext context, TagBuilder tagBuilder);
protected override bool ShouldApply(ContentAreaRenderingContext context, TagBuilder tagBuilder) { return(context.IsRenderingContentArea()); }
protected virtual void ApplyCore(ContentAreaRenderingContext context, TagBuilder tagBuilder) { var tag = GetContentAreaItemTemplateTag(context.ViewData, context.CurrentItemDisplayOption); tagBuilder.AddCssClass(string.Format($@"block {GetTypeSpecificClasses(context.CurrentItemContent)} {GetCssClassForTag(tag)} {tag}")); }
public void Apply(ContentAreaRenderingContext context, TagBuilder tagBuilder) { if(context.IsRenderingContentAreaItem()) ApplyCore(context, tagBuilder); }