Skip to content
This repository was archived by the owner on Dec 19, 2018. It is now read-only.
This repository was archived by the owner on Dec 19, 2018. It is now read-only.

Razor parser fails if tags balanced outside same code block #51

@NTaylorMullen

Description

@NTaylorMullen

Original Codeplex Issue: https://aspnetwebstack.codeplex.com/workitem/1537

The razor parser checks HTML tags to assure they are balanced. This seems like a nice thing to do except it does this check only within the current code block (between the same set of braces, for example). We ran into this when looping through a list of strings and doing layout by making the even-index strings on the left and odd-index strings on the right, two to a row. Each row is enclosed in a div. We tried to insert the outer div open tag before even indexes and the div close tag after the odd indexes, but this fails even though it seems like a reasonable thing to do. Something like below will fail because the "if" statement contains an open div tag, but no close. The div close tag is in a different if statement. Sure, there are work-arounds. (loop and outer code block omitted):

 bool even = (0 == (i % 2)); 
 var name = myNames[i]; 
 if (even) 
 {
 <div id="outerDiv"> <div class="leftColumn">@name</div> } // some other markup added here if (!even) { <div class="rightColumn">@name</div> </div> }

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions