class TemplateString
A string with substitutions, partially implements the AST interface.
Is automatically "splatted" into multiple expressions when the containing Cell is evaluated: the original string (str=), but with with substitution markers like #{1}, #{2} and so on and one expression for each substitution.
# symbols in the original string are escaped to ##.
index
static functions
-
TemplateString.subst(str, fn)
– apply substitutions to a template string. -
TemplateString\parse(pieces)
– parse a TemplateString (for parsing with Lpeg).
ast interface
-
templatestring\clone(parent)
– create a clone with its own identity. -
templatestring\stringify([depth])
– stringify this TemplateString.
details
static functions
-
– apply substitutions to a template string.
This also reverses the escaping that the parser applied.
parameters:
- the evaluated TemplateString.string
- function called with index i to obtain string to substitute
returns:
- (string)
- – parse a TemplateString (for parsing with Lpeg).
ast interface
-
– create a clone with its own identity.
creates a clone of this TemplateString by cloning all child expressions recursively.
parameters:
returns:
-
– stringify this TemplateString.
if depth is passed, does not faithfully recreate the original string but rather create useful debug output.
parameters:
- the maximum depth, defaults to infinite (optional)
returns:
- (string): the exact string this TemplateString was parsed from