question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

String interpolation in templates

See original GitHub issue

Currently 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:closed
  • Created 7 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
gmethvincommented, May 5, 2016

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.

0reactions
gmethvincommented, Dec 2, 2017

closing since there’s no clear way I see to introduce this new syntax without breaking changes.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found