StubbleOrg / Stubble

Trimmed down {{mustache}} templates in .NET
Other
405 stars 58 forks source link

CultureInfo support for rendering values. #78

Closed impworks closed 4 years ago

impworks commented 4 years ago

This PR adds the ability to explicitly specify a locale that will be used when rendering formattable values (float, double, decimal, etc.) to string.

Current spec expects the culture to be invariant, but never enforces it, so existing tests like "Basic Decimal Interpolation" fail on my machine because my locale is Russian and the decimal separator is a comma instead of a dot (weird, I know).

From now on, values be rendered using CultureInfo.InvariantCulture unless specified otherwise.

impworks commented 4 years ago

Not sure why the new test fails on CI. I ran all tests locally without any failures:

image

Romanx commented 4 years ago

Hi there, thanks very much for submitting a PR for this. I'll have a look at the code and then at the build to see whats happening

Romanx commented 4 years ago

@impworks I made some changes on your branch to bring the code more inline with the rest of the codebase.

The broken tests were related to the compilation renderer since the spec tests are shared. I worked on adding the culture info setting to the compilation renderer so now everything works as expected.

I'll get a release out for this shortly, please let me know if you have any issues and thank you very much for your contribution.