SmartFormat Documentation

repository·main·Indexed 23 days ago

https://github.com/axuno/smartformat

A lightweight, high-performance C# text templating library designed as an enhanced replacement for string.Format. It supports named placeholders, localization, pluralization, and lists, with optimizations for .NET 6.0 and .NET 8.0. The library provides both string.Format compatibility and an enhanced Smart.Format mode, allowing for custom source and formatter extensions.

Tokens
501
Snippets
0
Records
5
Agent score
29%

What's inside SmartFormat

  1. What is SmartFormat?

    main

    SmartFormat is a lightweight C# text templating library designed to format various data sources into strings using a minimal, intuitive syntax. It is highly compatible with string.Format but offers an enhanced mode called Smart.Format.

    Key characteristics include:

    • Runtime Formatting: All formatting occurs at runtime.
    • Extensibility: Uses extensions for named placeholders, localization, pluralization, gender conjugation, list formatting, and time formatting. Extensions can be nested.
    • Customization: Developers can easily implement custom source or formatter extensions via simple interfaces.
    • Control: Provides exact control over whitespace in text output.
  2. Overview of SmartFormat features

    main

    SmartFormat is a lightweight C# text templating library designed as a powerful replacement for string.Format. It supports named placeholders, lists, localization, and pluralization.

    Key features include:

    • High performance: Low memory footprint, especially optimized for .NET 6.0 and .NET 8.0.
    • Flexible syntax: Minimal and intuitive syntax with exact control over whitespace.
    • Dual modes: Supports both string.Format compatibility mode and an enhanced SmartFormat mode.
    • Extensible: Easy to integrate custom formatting and data source extensions.
    • Runtime formatting: All formatting occurs exclusively at runtime.
  3. Install SmartFormat via NuGet

    main

    You can install SmartFormat using NuGet. Depending on your requirements, choose either the full package (includes all built-in extensions) or the core package (minimal footprint).

    • Full package: Includes all built-in formatting extensions.
    • Core package: Provides the base functionality with a minimal footprint.
  4. Supported Target Frameworks for SmartFormat

    main

    SmartFormat is compatible with the following frameworks:

    • .NET Framework: 4.6.2 and later
    • .NET Standard: 2.0, 2.1
    • .NET Core/Modern: .NET 6.0 or .NET 8.0

    Note: For optimal performance and speed, it is recommended to use .NET 6.0 or .NET 8.0.