Quasi-literals for templating?

Mike Samuel mikesamuel at gmail.com
Wed Jun 15 17:49:29 PDT 2011

2011/6/15 Axel Rauschmayer <axel at rauschma.de>:
> Quick feedback: I haven’t seen SVE (substitution value expression?) defined anywhere and can’t find a description of using ${{var}} as syntactic sugar for "{var:${var}}".

SVE is defined in
reproduced below:


Production	 Result
QuasiLiteral :: QuasiTag`LiteralPortion QuasiLiteralTail	 SVE(QuasiLiteralTail)
QuasiLiteralTail :: Substitution LiteralPortion QuasiLiteralTail	
QuasiLiteralTail :: `	 an empty array
Substitution :: $Identifier	PrimaryExpression : Identifier
Substitution :: ${SubstitutionModifier Identifier}	PrimaryExpression
SubstitutionBody :: Identifier IdentifierPathTail	MemberExpression :
str-concat(SV(Identifier), SV(IdentifierPathTail))
IdentifierPathTail :: .IdentifierName IdentifierPathTail	
str-concat(“.”, SV(IdentifierName), SV(IdentifierPathTail))
IdentifierPathTail :: ε	 the empty string, ““

The SVE of a substitution is an expression that is evaluated in the
scope in which the quasiliteral appears. The SVE of the quasi literal
is the array of the SVE for each substitution.

E.g. the SVE of quasitag`literalPortion0 $x literalPortion1 $y.z
literalPortion2` is [x, y.z].

More information about the es-discuss mailing list