Open grebaldi opened 1 year ago
I think it’s like pythons f strings, except the f ^^ - so yes I like it ;)
also the ${ is less intuitive to write than a simple brace
Leading and trailing spaces are trimmed
i like phps behaviour of nowdocs better, there the indentation of the closing defines where each line starts
@mhsdesign
Like this?:
export component Foo {
bar: string
return """
Hello {bar}
"""
}
yes.
taken from the php doc:
The closing identifier may be indented by space or tab, in which case the indentation will be stripped from all lines in the doc string. [...]
If the closing identifier is indented further than any lines of the body, then a ParseError will be thrown:
// no indentation
return """
a
b
c
"""
// 4 spaces of indentation
return """
a
b
c
"""
output:
a
b
c
a
b
c
@mhsdesign:
i like phps behaviour of nowdocs better, there the indentation of the closing defines where each line starts
Agreed. I adjusted the issue description accordingly.
We'll need different delimiters, as """
cannot win against "
in expressions.
I'm currently trying:
return ---
Hello {bar}
---
but, dunno....
nvm... There needs to be an alternative to handling ambiguous tokens anyway, so """
can probably stay.
As of right now, template literals are modeled after ECMAScript, e.g.:
Imho this causes two problems:
${
sequence is a considerable complication for the parser (or better: The tokenizer)trim
ed away by the engine itselfI therefore suggest to change the template literal syntax to this:
Rules are:
This will still allow for possible future tagged template literals, like: