Skip to content
Message templates - the ability to format named string values, and capture the properties
F# PowerShell Other
Branch: master
Clone or download

Latest commit

Fetching latest commit…
Cannot retrieve the latest commit at this time.

Files

Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.vscode
src
test/FsMessageTemplates.Tests
tooling
.gitattributes
.gitignore
.travis.yml
Build.ps1
Install.ps1
LICENSE
README.md
appveyor.yml
build.cmd
build.sh
global.json
messagetemplates-fsharp.sln

README.md

FsMessageTemplates

An implementation of {named} string replacements, which allows formatting, parsing, and capturing properties.

FsMessageTemplates is compatible with the Message Templates Standard.

The F# implementation was designed to be paket-github referenced, or installed as a nuget package.

Build status NuGet

Samples

Format an F# Record

type User = { Id:int; Name:string }
format (parse "Hello, {@user}") [| {Id=1; Name="Adam"} |]
// > val it : string = "Hello, User { Id: 1, Name: "Adam" }"

Message Template Syntax

Message Templates are a superset of standard .NET format strings, so any format string acceptable to string.Format() will also be correctly processed by FsMessageTemplates.

  • Property names are written between { and } brackets
  • Brackets can be escaped by doubling them, e.g. {{ will be rendered as {
  • Formats that use numeric property names, like {0} and {1} exclusively, will be matched with the Format method's parameters by treating the property names as indexes; this is identical to string.Format()'s behaviour
  • If any of the property names are non-numeric, then all property names will be matched from left-to-right with the Format method's parameters
  • Property names may be prefixed with an optional operator, @ or $, to control how the property is serialised
  • Property names may be suffixed with an optional format, e.g. :000, to control how the property is rendered; these format strings behave exactly as their counterparts within the string.Format() syntax
You can’t perform that action at this time.