Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • joshpearce 5 posts 24 karma points
    Mar 07, 2011 @ 15:39
    joshpearce
    0

    Making a Template Using Razor

    Can a complete template be created using Razor?

  • Jonas Eriksson 930 posts 1825 karma points
    Mar 07, 2011 @ 15:48
    Jonas Eriksson
    0

    Hi,

    depends on how you mean, you can have a <umbraco:macro runat="server" language="razor"> ... </umbraco:macro> enclose the full template container - and that way have noting but razor building up that template.

    Regards

    Jonas

  • Sebastiaan Janssen 5058 posts 15520 karma points MVP admin hq
    Mar 07, 2011 @ 16:02
    Sebastiaan Janssen
    0

    You still have to work within the concept of masterpages as templates as Umbraco is still a WebForms based CMS. But as Jonas say, you could just include a razor macro and put everything in there.

  • Biagio Paruolo 1618 posts 1910 karma points c-trib
    Mar 08, 2011 @ 10:32
    Biagio Paruolo
    0

    Example?

  • Sebastiaan Janssen 5058 posts 15520 karma points MVP admin hq
    Mar 08, 2011 @ 11:00
    Sebastiaan Janssen
    0
    <%@ Master Language="C#" MasterPageFile="~/umbraco/masterpages/default.master" AutoEventWireup="true" %>

    <asp:Content ContentPlaceHolderID="ContentPlaceHolderDefault" runat="server">
     <umbraco:Macro Alias="Test" runat="server"></umbraco:Macro>
    </asp:Content>

    "Test" is a razor macro.

  • Aaron Powell 1708 posts 3046 karma points c-trib
    Mar 08, 2011 @ 23:10
    Aaron Powell
    0

    You can do a whole template in Razor by using inline macros (as Jonas has said). Keep the following in mind:

    * Razor wasn't designed for WebForms so the concept of a control does exist. This means that including macros in your Razor 'template' may be tricky

    * You'll loose so features like recursive field lookup, default field values and other things you can specify on <umbraco:Item

    * This is a theory and not a practice, I don't recommend you do it :P

  • Biagio Paruolo 1618 posts 1910 karma points c-trib
    Mar 20, 2011 @ 12:17
    Biagio Paruolo
    0

    Hi,

    >>* Razor wasn't designed for WebForms so the concept of a control does exist. This means that including macros in your Razor 'template' may be tricky

          Do you mean into asp.net form tag?

    >>* You'll loose so features like recursive field lookup, default field values and other things you can specify on <umbraco:Item

           Why? I read that Umbraco Razor supports every Umbraco Lib functions like XSLT.

    >>* This is a theory and not a practice, I don't recommend you do it :P

    ?

  • Sebastiaan Janssen 5058 posts 15520 karma points MVP admin hq
    Mar 20, 2011 @ 12:21
    Sebastiaan Janssen
    0

    I think what Slace was trying to say is that Razor was designed as an ASP.NET viewengine, not as a classic webforms server side control (basically anything that has a runat="server" attribute).

    Yes, it does support all of the XSLT extensions. Also, with the .AncestorOfSelf method you can do recursive lookup just fine.

    I wouldn't know why you should not do it, if you don't need server side controls then go for it.

Please Sign in or register to post replies

Write your reply to:

Draft