How can I get timestamp value in Twig?
There is other solution that might be easier to understand by designers. {{ ‘now’|date(‘U’) }} (I am aware that the question is already answered and it’s old)
There is other solution that might be easier to understand by designers. {{ ‘now’|date(‘U’) }} (I am aware that the question is already answered and it’s old)
Its not possible to access any PHP function inside Twig directly. What you can do is write a Twig extension. A common structure is, writing a service with some utility functions, write a Twig extension as bridge to access the service from twig. The Twig extension will use the service and your controller can use … Read more
Yea, it’s possible: {{ menu.getHTML(‘first-string’, ‘second-string’, [‘tab1’, ‘tab2’]) }} Since Twig handles getters and issers automatically, you can omit the get part: {{ menu.HTML(…) }}
I know it’s an old question, but just in case you don’t want to install a bundle like FOSJsRoutingBundle, here’s a little hack: var url=”{{ path(“yourroute”, {“region_id’: ‘region_id’}) }}’; url = url.replace(“region_id”, this.value); ‘region_id’ is just used as a placeholder, then you replace it in JS with your actual variable this.value
There is raw tag for this purpose: <script type=”text/x-handlebars”> {% raw %} {{#view App.MyView}} <h1>Hello world!</h1> {{/view}} {% endraw %} </script> Update As raw tag is deprecated use verbatim instead.
Wrong {% if var is not null and var is defined %} This does not work because a variable which is null in twig is defnied, but if you check for null first and it is not defined it will throw an error. Correct {% if var is defined and var is not null %} … Read more
Magic keyword for default value is value, not data. {{ form_widget(form.title, {‘value’ : ‘Default title’}) }}
In twig {{ ‘now’|date(‘d – m -Y’) }}