-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Labels
enhancementNew feature or requestNew feature or requestfeatureNew feature or requestNew feature or requesti18nInternationalization and localizationInternationalization and localization
Description
Description
Extend the format specifier system to support custom formatting for dates, numbers, and currency values.
Current State
- Boolean formatters implemented (
:checkbox,:yesno, etc.) - Basic architecture for format specifiers exists
- Need to extend to other data types
Proposed Formatters
Date Formatting
{{BirthDate:yyyy-MM-dd}} → 2025-01-15
{{DueDate:MMM dd, yyyy}} → Jan 15, 2025
{{CreatedAt:relative}} → 2 days ago
{{UpdatedAt:iso}} → 2025-01-15T10:30:00Z
Number Formatting
{{Price:N2}} → 1,234.56
{{Percentage:P1}} → 45.3%
{{Count:N0}} → 1,234
{{Scientific:E2}} → 1.23E+03
Currency Formatting
{{Amount:C}} → ,234.56 (culture-aware)
{{Amount:C:EUR}} → €1,234.56
{{Amount:C:GBP}} → £1,234.56
Custom Formatters
var options = new DocumentProcessorOptions
{
CustomFormatters = new Dictionary<string, IValueFormatter>
{
["phone"] = new PhoneFormatter(),
["ssn"] = new SocialSecurityFormatter(),
["uppercase"] = new UpperCaseFormatter()
}
};Technical Design
IValueFormatter Interface
public interface IValueFormatter
{
bool CanFormat(Type valueType, string format);
string Format(object value, string format, CultureInfo culture);
}Built-in Formatters
- DateTimeFormatter
- NumberFormatter
- CurrencyFormatter
- StandardFormatter (.NET format strings)
Culture Support
var options = new DocumentProcessorOptions
{
Culture = new CultureInfo("de-DE"),
// {{Amount:C}} → 1.234,56 € (German format)
};Use Cases
- Financial documents with currency
- Reports with dates in specific formats
- Multi-language document generation
- Scientific/technical documents
- Invoices and receipts
Acceptance Criteria
- Date formatting with standard .NET format strings
- Number formatting with standard .NET format strings
- Currency formatting with culture support
- Custom formatter registration
- Culture-aware formatting
- Fallback for invalid formats
- Comprehensive tests
- Documentation and examples
Priority
Medium - Highly requested feature
Backwards Compatibility
- Fully backwards compatible
- Format specifiers are optional
- Existing templates continue to work
References
- .NET format strings
- Issue Feature: Add format specifiers for boolean values (checkbox, yes/no, etc.) #1 (Boolean formatters - already implemented)
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or requestfeatureNew feature or requestNew feature or requesti18nInternationalization and localizationInternationalization and localization