Take the 2-minute tour ×
Tridion Stack Exchange is a question and answer site for Tridion developers and administrators. It's 100% free, no registration required.

I have one simple question:

We are using Razor templating in Tridion 2013 SP1. Is it including the Experience manager tags to the generated html? Or Do we need to add the EM tags manually?

share|improve this question
add comment

1 Answer

up vote 7 down vote accepted

Some tags are written out automatically, for example if you use the RenderComponentPresentation() method it will output the markup for a component presentation, and if you use RenderComponentField() it will output the markup for a field.

New in 2013 SP1 are the FieldStartMarker(), FieldValueStartMarker(), FieldEndMarker() and FieldValueEndMarker() functions, which are not in the current version of the Razor Mediator.

As a workaround on the project I am working on I created these as helper functions, in a TBB which is imported in all TBBs, I expect these will be included in the mediator in a future release...

@using Tridion.ContentManager.Templating.Expression
@using Tridion.ContentManager.ContentManagement
@using Tridion.Extensions.Mediators.Razor.Models

@helper FieldStartMarker(string fieldExpression)
{ 
    var fn = new BuiltInFunctions(TridionHelper.Engine, TridionHelper.Package);
    @fn.FieldStartMarker(fieldExpression)
}
@helper FieldEndMarker()
{
    @:</tcdl:Field>
}
@helper FieldValueStartMarker(int index=0)
{
    @:<tcdl:FieldValue index="@index">
} 
@helper FieldValueEndMarker()
{
    @:</tcdl:FieldValue>
}
share|improve this answer
    
Thank you, Will. This is our first project using Razor and we are investigating all the possibilities. Could you post a Razor Template with an example of using this helper? –  Guskermitt Feb 20 at 8:13
    
Theres plenty of info on importing TBBs in the Razor Mediator documentation, and also example Template code. The new Field..Marker functions are documented (in Dreamweaver syntax - but you will get the idea) in the online docs: sdllivecontent.sdl.com/LiveContent/web/… –  Will Price Feb 20 at 10:06
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.