Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support string interpolation #277

Open
tremby opened this issue Dec 10, 2015 · 7 comments
Open

Support string interpolation #277

tremby opened this issue Dec 10, 2015 · 7 comments

Comments

@tremby
Copy link

tremby commented Dec 10, 2015

It doesn't look like string interpolation is supported.

See http://twig.sensiolabs.org/doc/templates.html#string-interpolation

@r3wt
Copy link

r3wt commented Dec 12, 2015

kind of a pointless feature don't you think? since any valid expression will already work inside of a double quoted string with the correct syntax ie {{}} or {%%}

@tremby
Copy link
Author

tremby commented Dec 12, 2015

No, I don't think so.

In case we're talking at cross purposes, the feature affects a double-quoted string which is already inside {{}} or {%%}. So instead of {{ "foo " ~ bar ~ " baz" }} you can do {{ "foo #{bar} baz" }}.

@plepe
Copy link
Contributor

plepe commented Dec 16, 2015

I'm not sure if it is easy to support. Maybe @connorhu can support it in his lexer branch?

@TheLarkInn
Copy link

TheLarkInn commented May 31, 2017

One scenario I encountered was a situation like this:

{% extends "core::#{globals.twig.master}" %}

@Webslung
Copy link

Webslung commented Mar 7, 2018

Is this issue still in the pipeline? I have the same issue using a macro:

{{ svg.svg({class:"miz-comp-button_search--icon",title:"Search"},{href:"#{site.parent_theme}images/icons/miz-sprite.svg#action--search"}) }}

Just renders:

<svg class="miz-icon--sm miz-comp-button_search--icon" aria-hidden="true" focusable="false" title="Search">
  <use xlink:href="#{site.parent_theme}images/icons/miz-sprite.svg#action--search"></use>
</svg>

Any solutions or just isn't supported?

@Grawl
Copy link

Grawl commented Sep 19, 2018

looks like it's not working for now

input:

{% set foo = 'bar' %}
{{ "#{foo} baz" }}

output:

#{foo} baz

@drzraf
Copy link
Contributor

drzraf commented Dec 23, 2019

Really a must-have since this feature is heavily used in existing Twig template.
Twing's lexer supports it, may worth switching it (avoid NIH and combinate efforts)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

9 participants