messagetemplates / messagetemplates-fsharp

Message templates - the ability to format named string values, and capture the properties
http://messagetemplates.org/
Apache License 2.0
18 stars 4 forks source link

only destructure once consider capture symbol when capturePositionals ? #24

Open lust4life opened 6 years ago

lust4life commented 6 years ago

type User = 
  {
    id      : int 
    name    : string
    created : DateTime
  }
with
  interface IFormattable with
    member x.ToString (format, provider) =
      sprintf "id => %i, name => %s, created => %A" x.id x.name (x.created.ToShortDateString())

let foo = { id = 999; name = "foo"; created = DateTime.Now}
let nl = Environment.NewLine + Environment.NewLine

Formatting.format (Parser.parse "{0} {1} {$0} {1} {@0}") [| foo; nl |] 

output:

> Formatting.format (Parser.parse "{0} {1} {$0} {1} {@0}") [| foo; nl |]

val it : string =
  ""{id = 999;
 name = \"foo\";
 created = 11/3/2017 7:54:35 PM;}" "

" "{id = 999;
 name = \"foo\";
 created = 11/3/2017 7:54:35 PM;}" "

" "{id = 999;
 name = \"foo\";
 created = 11/3/2017 7:54:35 PM;}""

hi, do we support template like this ? "{0} {1} {$0} {1} {@0}"