RazorEngine icon indicating copy to clipboard operation
RazorEngine copied to clipboard

HTML Encoding not working for @helper

Open lloydcotten opened this issue 14 years ago • 0 comments

Hi,

It appears that values are not being encoded when inside a helper. Here is a unit test which is failing for me.

[Test]
public void TemplateService_CanParseSimpleHelperTemplate_UsingHtmlEncoding()
{

    using (var service = new TemplateService())
    {
        const string template = "<h1>Hello @NameHelper()</h1> @helper NameHelper() { <i>@Model.String</i> }";
        const string expected = "<h1>Hello <i>Matt &amp; World</i></h1>";

        var model = new { String = "Matt & World" };
        string result = service.Parse(template, model, null, null);

        Assert.That(result == expected, "Result does not match expected: " + result);
    }
}

I would like to fix this, but I'm having trouble drilling down exactly where this occurs. Can you provide any pointers?

Thanks, Lloyd

lloydcotten avatar Oct 02 '12 18:10 lloydcotten