Templates in Lemoon

Templates are used to render content items. You normally specify that all content of a content type should have the same template, but you can always override the template selection for an individual content item (page).

A template in Lemoon is a standard ASP.NET Web Page (.aspx). A web page is divided into two separate pieces, the visual part and the logic. The visual part consists of static html, server controls, scripts and so on. The logic of the page consists of code that interacts with the page. The code often resides in a separate file which is called the "code-behind" file. The code-behind file can be written in either VB.NET (.vb) or C# (.cs)

All templates that you want to use must be located in the /Lemoon/Templates folder. The templates should inherit from the generic PageBase<T> class in order to take full advantage of the rendering flow where properties like Content and Site are available. The Content property holds the content item currently being rendered and the Site property holds information about the current site (a Lemoon installation can contain many sites).

using System;
using Mindroute.Lemoon.Modules.CoreModule;
using Mindroute.Lemoon.Web.UI;
namespace MyProject.Lemoon.Templates {
    public partial class PageTemplate : PageBase<Page> {
        protected void Page_Load(object sender, EventArgs e) {

Because templates are generic you have access to a strongly type Content property in both the "code-in-front" and the "code-behind". For example, if you have a property called Body in the content type Page, you can type Content.Body directly in the visual part of template. This means that most of the time you will not have to bother with user- and web controls. Is is often simpleer to render the properties of the content type directly via "code nuggets". It almost feels a bit like ASP.NET MVC.

<%@ page title="" language="C#" masterpagefile="~/Lemoon/MasterPages/Site.Master" autoeventwireup="true" codebehind="PageTemplate.aspx.cs" inherits="MyProject.Lemoon.Templates.PageTemplate" %>
<asp:content contentplaceholderid="mainplh" runat="server">
  <h1><%: Content.Title %></h1>
  <%= Content.Body %>