Skip to content

Conversation

@patrikwlund
Copy link

The value is only formatted for the correct culture if the token requests that the value is escaped (i.e. obj.EscapeResult). Otherwise it just calls StringBuilder.Append() with the raw value, which does not use the configured culture of our CompilationSettings.

Benchmarks

I did not notice any meaningful difference in benchmarks. I included Nustache as a baseline.

Method Index Mean Error StdDev Renderer Gen 0 Gen 1 Allocated
Stubble_Before 1 743.0 ns 10.94 ns 9.70 ns Stubble 0.4292 0.0038 3 KB
Nustache_Before 1 12,082.0 ns 231.74 ns 317.21 ns Nustache 3.6774 0.0916 23 KB
Stubble_After 1 725.8 ns 11.44 ns 10.70 ns Stubble 0.4292 0.0038 3 KB
Nustache_After 1 11,601.8 ns 122.77 ns 108.83 ns Nustache 3.6774 0.0916 23 KB

Background

I noticed this issue because these two interpolation tests failed on my PC:

  • Triple Mustache Decimal Interpolation
  • Ampersand Decimal Interpolation
Expected: "1.21 jiggawatts!"
Actual:   "1,21 jiggawatts!"

My PC has Swedish formatting settings and thus uses , instead of . as a decimal separator.

…ting

The value is only formatted for the correct culture if the token requests that the value is escaped (i.e. `obj.EscapeResult`). Otherwise it just calls `StringBuilder.Append()` with the raw value, which does not use the configured culture of our `CompilationSettings`.

## Benchmarks
I did not notice any meaningful difference in benchmarks. I included Nustache as a baseline.
|             Method | Index |        Mean |     Error |    StdDev | Renderer |  Gen 0 |  Gen 1 | Allocated |
|------------------- |------ |------------:|----------:|----------:|--------- |-------:|-------:|----------:|
|  Stubble_Before |     1 |    743.0 ns |  10.94 ns |   9.70 ns |  Stubble | 0.4292 | 0.0038 |      3 KB |
| Nustache_Before |     1 | 12,082.0 ns | 231.74 ns | 317.21 ns | Nustache | 3.6774 | 0.0916 |     23 KB |
|  Stubble_After |     1 |    725.8 ns |  11.44 ns |    10.70 ns |  Stubble | 0.4292 | 0.0038 |      3 KB |
| Nustache_After |     1 | 11,601.8 ns | 122.77 ns |   108.83 ns  | Nustache | 3.6774 | 0.0916 |     23 KB |

## Background
I noticed this issue because these two interpolation tests failed on my PC:
- `Triple Mustache Decimal Interpolation`
- `Ampersand Decimal Interpolation`

```
Expected: "1.21 jiggawatts!"
Actual:   "1,21 jiggawatts!"
```

My PC has Swedish formatting settings and thus uses `,` instead of `.` as a decimal separator.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant