0

Using an if statement while templating using the Razor mediator:

@if (...) {
    <text><div></text>
}
@if (...) {
    <text><div></text>
}
@if (...) {
    <text></div></text>
}

But while using these <text> tags, sometimes extra </text> tags will be rendered out for no apparent reason. Any idea why these are being rendered out?

0

It appears that the Razor mediator does not test for tag name when attempting to balance tags. I was able to fix this by removing some of the <text> tags.

@if (...) {
    <div></text>
}
@if (...) {
    <div></text>
}
@if (...) {
    <text></div>
}

Additionally, this issue could be avoided altogether by utilizing a different method to render unbalanced tags altogether as mentioned in this post: How to include partial (unbalanced) html in a Razor Mediator if statement?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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