String interpolation in templates
See original GitHub issueCurrently Twirl does not support string interpolation in templates, I think mostly because simple string interpolation can be done with Twirl itself, like Hello, @name!
. But more complex string interpolators cannot be substituted with Twirl. The sample of such interpolator is a translating interpolator at my project, Scalingua. Currently we have to write
@(t"Hello, world!")
Could Twirl compiler support shorter and cleaner version of it, something like
@t"Hello, world!"
This is a pretty minor issue, of course, but these parentheses looks ugly, and adding string interpolation syntax should not break any existing code.
Issue Analytics
- State:
- Created 7 years ago
- Comments:6 (4 by maintainers)
Top Results From Across the Web
Template literals (Template strings) - JavaScript | MDN
Template literals are sometimes informally called template strings, because they are used most commonly for string interpolation (to create ...
Read more >JavaScript Template Literals - W3Schools
Template literals provide an easy way to interpolate variables and expressions into strings. The method is called string interpolation. The syntax is:.
Read more >How can I do string interpolation in JavaScript? - Stack Overflow
Since ES6, you can use template literals: const age = 3 console.log(`I'm ${age} years old!`) Run code snippet. Hide results. Expand snippet ...
Read more >Displaying values with interpolation - Angular
Interpolation refers to embedding expressions into marked up text. ... Angular replaces currentCustomer with the string value of the corresponding component ...
Read more >Template strings & interpolation in Ionic 2
TypeScript provides a much simpler and easier syntax to accomplish the above. Using a combination of template strings and interpolation we can mix...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I think that introduces some ambiguity, though, or at least a backwards-incompatible syntax change. Now
@t"foo"
is an interpolated string, whereas before it was a variable followed by a literal quoted string.closing since there’s no clear way I see to introduce this new syntax without breaking changes.