jehugaleahsa / mustache-sharp

An extension of the mustache text template engine for .NET.
The Unlicense
306 stars 80 forks source link

Removal of newlines in HtmlFormatCompiler actually causing a problem #90

Open ericnewton76 opened 5 years ago

ericnewton76 commented 5 years ago

Odd case where something in an SMTP server is truncating at 1000 characters per line. Probably a dumb C++ newline splitter with a max of 1000 per line.

Since mustache FormatCompiler and HtmlFormatCompiler both ignore the \n in my html templates, I run into this problem...

IMO, HtmlFormatCompiler shouldn't remove newlines... what's the point?

If I submit a PR that adds an options property for HtmlFormatCompiler that turns this on or off, would you consider it?

ericnewton76 commented 5 years ago

Now I'm looking at the HtmlFormatCompiler source and see RemoveNewLines = true in the constructor, and now I'm scratching my head as to why you're using FormatCompiler hidden away in a private variable?

https://github.com/jehugaleahsa/mustache-sharp/blob/master/MustacheSharp/HtmlFormatCompiler.cs#L13

Is there some reason why not to use an interface for both, or even HtmlFormatCompiler subclass of FormatCompiler? I'm curious as to your decisions on this.

Which as a workaround makes things even more difficult since I'll have to resort to using reflection to modify the FormatCompiler private variable to preserve newlines.