Best practice for re-usable blocks

Hi, I’m having some trouble desciding what’s the best way to do the following, and I’m hoping someone could be of any assistence.

I have a App_Code\Helpers.cshtml that contains (ofcourse) some helper-functions.

For instance, a function that renders a list of blocks for a given list of content-items.

I came a cross of limitations.

  • I can’t use things such as GetPropertyValue() on an IPublishedContent
  • I don’t have access to @Html to use the .Raw() or .RenderPartial() functions.
  • I need to create an instance of the @UmbracoHelper in every function.
  • Because this file is compiled on runtime, a single change makes the first page-visit really slow when developing. Even the first page-visit within the backend takes quite some time after an edit.

Just to name a few.

I try to use PartialMacro’s when possible, but I think the possible parameter for a PartialMacro are limited. I can’t create a PartialMacro that accepts a List<DynamicPublishedContent> for instance. As far as I know.

What would be the best way to use these functions? Any suggestions?


This is a companion discussion topic for the original entry at https://our.umbraco.com/forum/74927-best-practice-for-re-usable-blocks