Template Engine for Umbraco

Zone
Zone’s open source sauce
3 min readJun 7, 2016

The following is one of a series of posts introducing various open-source projects Zone has developed and made available for others to use. Some come from personal side-projects and others where we’ve been able to identify general solutions to specific problems we’ve worked on for our clients — who we thank for allowing their contribution to these projects to be released in this manner. In this article Neil Cumpstey introduces his Template Engine, an Umbraco package that provides functionality allowing reuse of single items of content in various places on a website.

One of the challenges of designing a website is enabling the users to easily access the content they are looking for. This inevitably means that content (whether an article, video, recipe, downloadable resource) will be presented on the website in several different places: as a page in its own right, as an item in search results, as a featured item in a banner. How to present the same content in different places is just one of the challenges for a developer, but sometimes a difficult one.

Take, for example, the resource area on the Tesco Eat Happy Project website. This searches four different resource types, and presents them as four different (though visually similar) templates within the same list — different highlight colours, different subtitles, some with download links and some without.

Resources page on Tesco’s Eat Happy Project website

Even using the MVC approach enabled by Andy’s Umbraco Mapper project, which simplifies the building of view models and allows views to be kept simple, rendering this type of mixed-content list would generally involve significant logic in either the controller or the view, or both.

Further reuse of the same content elsewhere on the website would require additional logic, even if each item is displayed in a visually identical template — such as manually or automatically chosen related content.

The Umbraco Template Engine removes the complexity involved in reuse of content on the website. Templates can be built for each content type for each usage on the website, and the Template Engine takes care of the difficult logic of rendering the content with the correct template. It even allows the simple embedding of existing content into rich text areas.

For more information, including an example website showing the usage, please see the project’s GitHub page.

--

--

Zone
Zone’s open source sauce

We write about customer experience, employee experience, design, content & technology to share our knowledge with the wider community.