Hello I'm having problems with a macro.
in macros.html.twig
{% macro panel_header(title) %}
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">{{ title|escape('html') }}
</div>
{% endmacro %}
in profile.show.html.twig
{% import "macros.html.twig" as macros %}
{{ macros.panel_header("hello" {{profile.name}} ) }}
Above example doesn't work because it asks that arguments are separated by a comma
{{ macros.panel_header("hello {{profile.name}}" ) }}
This outputs "hello {{profile.name}} which makes sense ofcourse
So my question is how can i add a string and a variable as a single argument to a macro?
kachar :
String interpolation (#{expression}) allows any valid expression to appear within a double-quoted string. The result of evaluating that expression is inserted into the string:\n\n{{ \"foo #{bar} baz\" }}\n{{ \"foo #{1 + 2} baz\" }}\n\n{{ macros.panel_header(\"hello #{profile.name}\") }}\n\n\nString interpolation was added in Twig 1.5",
2013-11-06T02:41:18