This is done segment by segment, and static template portions as well as substitutions
are added individually to the returned CompositeGeneratorNode.
At that common leading indentation of all the template's static parts is trimmed,
whereas additional indentations of particular lines within that static parts as well as
any line breaks and indentation within the substitutions are kept.
For the sake of good readability and good composability of results of this function like
in the following example, the subsequent rule is applied.
expandToNode` This is the beginning of something
${foo.bar?expandToNode` bla bla bla ${foo.bar}
`:undefined} end of something `
Rule:
In case of a multiline template
the content of the first line including its terminating line break is ignored,
if and only if it is empty or contains whitespace only.
the content of the last line including its preceding line break (last line within the template excluding the trailing backtick) is ignored,
if and only if it is empty or contains whitespace only, and the whitespace in-between the last line break and the trailing backtick
is a real prefix of the common indentation among all none-empty lines of the template, i.e.,
it is shorter than the common indentation that is trimmed during processing the template provided that common indentation is identifiable.
Thus, the results of all of the following invocations are identical and equal to generatedContent.
In addition, a third rule is applied while processing line breaks:
If a line's last substitution contributes undefined or an object of type GeneratorNode,
the subsequent line break will be appended via CompositeGeneratorNode.appendNewLineIfNotEmpty.
Hence, if all other segments of that line contribute whitespace characters only,
the entire line will be omitted while rendering the desired output.
Otherwise, linebreaks will be added via CompositeGeneratorNode.appendNewLine.
That holds in particular, if the last substitution contributes an empty string. In consequence,
adding ${''} to the end of a line consisting of whitespace and substitutions only
enforces the line break to be rendered, no matter what the substitutions actually contribute.
A tag function that attaches the template's content to a CompositeGeneratorNode.
This is done segment by segment, and static template portions as well as substitutions are added individually to the returned CompositeGeneratorNode. At that common leading indentation of all the template's static parts is trimmed, whereas additional indentations of particular lines within that static parts as well as any line breaks and indentation within the substitutions are kept.
For the sake of good readability and good composability of results of this function like in the following example, the subsequent rule is applied.
Rule: In case of a multiline template
Thus, the results of all of the following invocations are identical and equal to
generatedContent.In contrast, the results of the following invocations are equal to
generatedContent\n(orgeneratedContent\r\non MS Windows)In addition, a third rule is applied while processing line breaks: If a line's last substitution contributes
undefinedor an object of type GeneratorNode, the subsequent line break will be appended via CompositeGeneratorNode.appendNewLineIfNotEmpty. Hence, if all other segments of that line contribute whitespace characters only, the entire line will be omitted while rendering the desired output. Otherwise, linebreaks will be added via CompositeGeneratorNode.appendNewLine. That holds in particular, if the last substitution contributes an empty string. In consequence, adding${''}to the end of a line consisting of whitespace and substitutions only enforces the line break to be rendered, no matter what the substitutions actually contribute.