Below is the block of code that I'm having a problem with.

<ul class="description-tabs-menu--tabs-nav">
    @foreach(var fields in Component.Fields.product_tabs){
        <a href="#@fields.tab_target_name"
        <span class="tab-bg-left"></span>
        <span class="tab-bg-tip"></span>

When attempting to save the template in Tridion, I get the following error:

TemplateCompileException: CS1513: } expected

Line 599 Column 33: Write(fields.tab_target_name);


  • if(fields.IsFirst){ class="active" }WriteLiteral(" >\n ");

CS1001: Identifier expected

Line 600 Column 22: WriteLiteral("\"\n");

if(fields.IsFirst){ * class="active" }WriteLiteral(" >\n ");

Can someone point to a solution?

2 Answers 2


Try using the <text> wrapper around your statements, in order to help the parser identify them properly.

See https://stackoverflow.com/questions/5369540/razor-renderpartial-exception-expected


I think you might be better to write that like this using a terniary operator

<a href="#@fields.tab_target_name" @(fields.IsFirst ? "class=\"active\"" : "")>

As Mihai points out the parser is struggling to identify what is code and what isn't. This should make it a little easier for it.

  • Please mark this as the answer so it can help others.
    – Nuno Linhares
    Nov 1, 2013 at 0:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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