README (935B)
1 This module provides support for formatting of large or complex strings beyond 2 the scope of [[fmt::]]. A template is compiled using [[compile]], then executed 3 with [[execute]] to print formatted text to an [[io::handle]]. 4 5 The template format is a string with variables substituted using "$". Variable 6 names must be alphanumeric ASCII characters (i.e. for which [[ascii::isalnum]] 7 returns true). A literal "$" may be printed by using it twice: "$$". Variables 8 may also be used with braces, i.e. ${variable}, so that they can be placed 9 immediately next to alphanumeric characters; such variables may include 10 non-alphanumeric characters other than '{' and '}'. 11 12 const src = "Hello, $user! Your balance is $$$balance.\n"; 13 const template = template::compile(src)!; 14 defer template::finish(&template); 15 template::execute(&template, os::stdout, 16 ("user", "ddevault"), 17 ("balance", 1000), 18 )!; // "Hello, ddevault! Your balance is $1000.