Validate Razor template
<p>How can I validate Razor template, which is used to render mail template.</p>

<pre><code>string template = @"
My template 
@if (Model.Condition { &lt;span&gt;is true&lt;/spaM&gt; }"
</code></pre>

<p>I made two mistakes: missing closing bracket and wrong closing tag.
I need to validate it and known what should I fix (the best is to known in which line). I would like to use native Razor methods.</p>