From 63cdc4605d03635af45210f3fe7e4479bfe098ed Mon Sep 17 00:00:00 2001 From: s-ol Date: Mon, 4 Aug 2025 23:09:16 +0200 Subject: docs/reference: add template string section --- spec/internal/parsing_spec.moon | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'spec') diff --git a/spec/internal/parsing_spec.moon b/spec/internal/parsing_spec.moon index 47de338..8f9b79e 100644 --- a/spec/internal/parsing_spec.moon +++ b/spec/internal/parsing_spec.moon @@ -134,6 +134,18 @@ describe 'TemplateString parsing', -> node = verify_parse tplstr, '$hi"\\$(this would\\${3}be invalid!"' assert.is.same {'$(this would${3}be invalid!'}, node.children[2]\eval!.result! + test 'can contain quotes', -> + node = verify_parse tplstr, '$hi"$"this" is a string"' + assert.is.same {'', ' is a string'}, node.children[2]\eval!.result! + assert.is.same 'this', node.children[3]\eval!.result! + + node = verify_parse tplstr, '$hi"a string is $"this""' + assert.is.same {'a string is ', ''}, node.children[2]\eval!.result! + assert.is.same 'this', node.children[3]\eval!.result! + + node = verify_parse tplstr, '$hi"uh $(= "a" "b") huh"' + assert.is.same {'uh ', ' huh'}, node.children[2]\eval!.result! + test 'can be applied', -> node = verify_parse tplstr, '$[123]hi" string with $3$5 some $(= "contents") "' substituted = node.__class.subst node.children[2]\eval!.result!, {123, "foot", " where "} -- cgit v1.2.3