Search code examples
htmldust.js

Dust.js templates outputting 


I have a dust template that is using a partial to render fields in a form:

{#Person}
{>"partial/field" field="FirstName" /}
{>"partial/field" field="MiddleName" /}
{>"partial/field" field="LastName" /}
{/Person}

This is resulting in HTML that looks mostly correct, except there's strange spacing in between each field's output. When I inspect the markup using Chrome's developer tools, I see a mysterious HTML non-breaking space entity being output as  but I didn't put it there.


Solution

  • The solution turned out to be that I had to change the encoding for the partial template file from UTF-8 to Codepage 1252. Since I use Visual Studio, this was pretty easy: use File > Advanced Save Options...

    It appears that entity  is used as the UTF byte order marker and was being output into the resulting HTML. Hope this helps someone else struggling with this!