I'm curious if I can somehow make the Widget.Wrapper shape (or other wrappers) alternateable, because it contains most of the widgets' HTML code. I don't like rich IF statements in cshtml files, therefore I'd rather use a clear solution using the alternates mechanism - being able to create alternates like these:
Widget.Wrapper-[ZoneName].cshtml
Widget.Wrapper-[WidgetId].cshtml
Widget.Wrapper-url-[UrlAlternate开发者_运维技巧].cshtml
etc.
Is that possible? Or are the wrappers a special case - and in that case why?
Thanks
Yes, it's possible. You can do it with IShapeTableProvider. Catch the shape that your widget it rendering, decide which wrapper you want, and then add a new wrapper.
builder.Describe("YourShapeHere")
.OnDisplaying(displaying=>{
displaying.ShapeMetadata.Wrappers.Add("Widget_Wrapper-" + displaying.Shape.Id);
}
}
精彩评论