Add money filters - #963
Merged
Merged
Conversation
Implements the Shopify money filters, registered with the opt-in
`FilterCollection.WithMoneyFilters()`:
- money
- money_with_currency
- money_without_currency
- money_without_trailing_zeros
Formatting is derived from `TemplateOptions.CultureInfo` by default, and
configured by the new `TemplateOptions.MoneyOptions`, which is mirrored on
`TemplateContext` so a currency can be selected per rendering.
- `Currency` and a per-call filter argument select an ISO 4217 currency,
resolved against an extensible `Currencies` collection.
- `AmountsInCents` divides the input by 100, matching Shopify where prices
are stored as integers.
- `MoneyFormat` and `MoneyWithCurrencyFormat` override the culture based
formatting using the Shopify placeholders, plus `{{currency}}` and
`{{currency_symbol}}`.
Fixes sebastienros#238
Collaborator
|
Just a little note before reviewing why we simplify this by having one |
Owner
|
AGENTS.md instead? |
The two files were both agent guidance for this repository, with the commands and testing sections overlapping. AGENTS.md is now the single file, and CLAUDE.md is removed.
Collaborator
Author
Merged into AGENTS.md |
sebastienros
pushed a commit
that referenced
this pull request
Aug 20, 2026
* Add money filters
Implements the Shopify money filters, registered with the opt-in
`FilterCollection.WithMoneyFilters()`:
- money
- money_with_currency
- money_without_currency
- money_without_trailing_zeros
Formatting is derived from `TemplateOptions.CultureInfo` by default, and
configured by the new `TemplateOptions.MoneyOptions`, which is mirrored on
`TemplateContext` so a currency can be selected per rendering.
- `Currency` and a per-call filter argument select an ISO 4217 currency,
resolved against an extensible `Currencies` collection.
- `AmountsInCents` divides the input by 100, matching Shopify where prices
are stored as integers.
- `MoneyFormat` and `MoneyWithCurrencyFormat` override the culture based
formatting using the Shopify placeholders, plus `{{currency}}` and
`{{currency_symbol}}`.
Fixes #238
* Merge CLAUDE.md into AGENTS.md
The two files were both agent guidance for this repository, with the
commands and testing sections overlapping. AGENTS.md is now the single
file, and CLAUDE.md is removed.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: ee9c8775-0354-41dd-8226-89a69c60241c
This was referenced Aug 21, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #238
Implements the Shopify money filters, registered with the opt-in
FilterCollection.WithMoneyFilters()(likeWithColorFilters(), they are not added by theTemplateOptionsconstructor):money{{ 1134.65 | money }}$1,134.65money_with_currency{{ 1134.65 | money_with_currency }}$1,134.65 USDmoney_without_currency{{ 1134.65 | money_without_currency }}1,134.65money_without_trailing_zeros{{ 10.00 | money_without_trailing_zeros }}$10Configuration
A new
TemplateOptions.MoneyOptions, mirrored onTemplateContextso a currency can be selected per rendering:TemplateOptions.CultureInfo. The invariant culture has no region, soUSD/$is used, which matches Shopify's default${{amount}}format.Currency, an ISO 4217 code, also accepted as a filter argument:{{ 10 | money: 'EUR' }}and{{ 10 | money: currency: 'EUR' }}. Symbols and decimal digits come from an extensibleCurrenciescollection seeded with the common codes; an unregistered code is rendered using the code itself as the symbol.AmountsInCents(defaultfalse) divides the input by 100, for templates ported from Shopify where prices are stored as integers.MoneyFormat/MoneyWithCurrencyFormatoverride the culture based formatting with the Shopify currency formatting placeholders ({{amount}},{{amount_with_comma_separator}}, …), plus{{currency}}and{{currency_symbol}}so a single format works with a currency resolved at rendering time. Formats are parsed once, when assigned.Notes
Amounts default to plain decimals rather than cents. The issue comment on #238 is a good illustration of what people expect:
{{ item.Price | money_without_currency }}currently falls through unfiltered and renders31.300or31.30depending on the scale of thedecimalthat came out of the database. Money formatting pins the decimal count, and there is a test for it.Two deliberate deviations from raw .NET currency formatting, both overridable with a format string:
-$10.00rather than the accounting($10.00)that"C"produces for en-US and the invariant culture.README.mdhas a new "Money filters" section, andCLAUDE.mdis added.Testing
70 new tests in
Fluid.Tests/MoneyFiltersTests.cs. Full suite passes on both the regular and theCompiled=truepass, and the build is clean on all four TFMs including netstandard2.0.