twig-extension

Symfony 2 production app unable to find any Twig template

我们两清 提交于 2019-12-13 03:58:39
问题 I made Symfony 2 app what is working well on production and dev mode in my localhost server, but when i pushed it live to my ftp there was a problem. I checked log's and it's looks like Twig has problems with finding templates. There is log from my server: [2015-05-18 11:10:21] request.INFO: Matched route "homepage" (parameters: "_controller": "AppBundle\Controller\DefaultController::indexAction", "_route": "homepage") [] [] [2015-05-18 11:10:21] security.INFO: Populated SecurityContext with

Twig dump isn't printing anything

泄露秘密 提交于 2019-12-10 20:51:23
问题 I am a little bit confused right now. I always used the twig dump function like any other twig function but now it has absolutely no output. No errors/exceptions, just nothing. Everything else is working fine, like the trans filter. {{ dump('test') }} # prints nothing {{ 'layout.booking.chooseArea'|trans }} # prints the translated message Right now this template doesn't contain anything more than that. The dump also doesn't work in the parent template or in base.html.twig. Again, the dump

How to return and insert HTML code with a Twig function?

▼魔方 西西 提交于 2019-12-10 10:47:38
问题 I'm trying to add some images dynamically with Twig. So I defined a new Twig function called setImgService which basically chechs for a service name and depending on it, it will return some HTML code according to its image. Function code: $setImgService = new Twig_SimpleFunction('setImgService', function($serviceName){ switch ($serviceName){ case "Analitycs": return '<img src="assets/img/analitycs.png">'; case "Hosting": return '<img src="assets/img/hosting.png">'; case "SEO": return '<img

Using Nested Include Twig

泪湿孤枕 提交于 2019-12-08 13:11:16
问题 in my header.twig : <ul class="nav list-unstyled"> {% for item in data %} {% include 'partials/item/header/item-nav.twig' %} {% endfor %} </ul> in my item-nav.twig <li><a href="{{ data.url }}">{{ data.menu_name }}</a></li> header.twig is included in base.twig. I rendered base.twig in base.php file. Where I can add data array to process data.url and data.name ? in base.php ? or i rendered file php again ? Thank you. base.php include __DIR__ . '/../vendor/autoload.php'; $renderer = new

How to return and insert HTML code with a Twig function?

青春壹個敷衍的年華 提交于 2019-12-06 08:37:55
I'm trying to add some images dynamically with Twig. So I defined a new Twig function called setImgService which basically chechs for a service name and depending on it, it will return some HTML code according to its image. Function code: $setImgService = new Twig_SimpleFunction('setImgService', function($serviceName){ switch ($serviceName){ case "Analitycs": return '<img src="assets/img/analitycs.png">'; case "Hosting": return '<img src="assets/img/hosting.png">'; case "SEO": return '<img src="assets/img/seo.png">'; case "Maintenance": return '<img src="assets/img/maintenance.png">'; case

How to get days difference in twig

耗尽温柔 提交于 2019-12-04 03:21:29
how to get days diffrence from current day. tweetedAt: "2015-02-22 09:56:42". twig {% for key,value in data.about %} {% set tweets_date=(value.tweetedAt|date).date("now").format('%a') %} {% endfor %} I have also tried {% set dd='now'|date('d-m-Y') %} {% set tweets_date=(value.tweetedAt|date).dd.format('%a') %} Finally I tried but its giving error: A hash key must be a quoted string, a number, a name, or an expression enclosed in parentheses (unexpected token "punctuation" of value "{" {% set difference = {{ date("m/d/Y") }}.diff(date(value.tweetedAt)) %} {% set leftDays = difference.days %}

Generate the HTML template equivalent of a twig file?

情到浓时终转凉″ 提交于 2019-12-02 15:38:58
问题 I'd like to know if it's possible to have {filename}.html generated for every {filename}.html.twig ? I know one solution is to copy and paste the source code from the browser, but is there a more efficient way of doing this? Thank you in advance. 回答1: Such solution, I think, will satisfy your needs. curl www.yoururl.com > /path/to/yourfolder/file.html Have a look below story, if you interested in. Story A few months ago, i was working on a yii2 project. The index page was loading in 3 seconds

Twig - display template names if debug mode is enabled

≯℡__Kan透↙ 提交于 2019-12-01 10:30:18
I'm using Twig lately and I was wondering if it is possible to output the template names which are loaded on the page. The best way I can think of is to display the name above the template itself as a html comment. <!-- start @default/_components/_wrapper/form-wrapper.html.twig --> <form> ... </form> <!-- end @default/_components/_wrapper/form-wrapper.html.twig --> I know that I can get the template name by inserting {{ _self.templateName }} but I don't like to add it to every template or partial. The solution should work for {% include %} , {% use %} etc and it would also be nice if it just

How to install the Intl extension for Twig

扶醉桌前 提交于 2019-11-27 07:06:47
The Intl extension is an extension for Twig that adds the localizeddate , localizednumber and localizedcurrency filters. How can I install and set up the extension so that I can use those filters in my Twig templates? Install the PHP intl extension First of all, you will need the PHP intl extension , as the Twig extension is built on top of that. The Twig Intl extension will throw an Exception if the PHP intl extension is not enabled. Installation instructions can be found in the official PHP documentation. On Ubuntu/Debian machines, this is as easy as running the following command: sudo apt