SUPPORT FOR THE .NET DLR

One of the most versatile aspects of Umbraco is its support for additional languages through the .NET Dynamic Language Runtime (DLR) text. Out of the box, you can create macros that are based on IronPython and IronRuby, simply by using the backoffice interface. This is a great alternative to XSLT and .NET driven macros for those who prefer working with a different language.

This section simply provides you with syntactical examples of how to render the content using these alternate languages. The author suggests the following online resources for further reading about the DLR languages mentioned in the following sections.

  • http://ironruby.codeplex.com/: This is an IronRuby open source project.
  • http://ironpython.codeplex.com/: This is an IronPython open source project.

For those of you who prefer working with IronPython or IronRuby, the examples in Listings 5-7, 5-8, and 5-9 should provide you with a good introduction on how to tap into the Umbraco content using one of these languages.

IronPython

Here are some examples of what you can do using IronPython as your language of choice in your Umbraco macros. The options are virtually endless, just like when you work with .NET.

Listing Pages from Current Page

In Listing 5-7, you can see how few lines of code it takes to generate an unordered list of pages using IronPython.

LISTING 5-7: PagesFromCurentNode.py

from umbraco.presentation.nodeFactory import Node from umbraco import library #list all of the subpages ...

Get Umbraco User's Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.