assetic

Symfony2: How to share js libs and css between bundles

梦想与她 提交于 2019-11-27 03:44:42
问题 I have different Bundles: MainBundle (Homepage), SecurityBundle (Login, Registration), MessageBundle (Message System), ShopBundle. I also follow the three stage layout schema (::base.html.twig, AcmeMainBundle::layout.html.twig, AcmeMainBundle:Default:index.html.twig). But I have problems sharing common js libaries through the application (e.g. jquery) and defining a base.css (which sets some base classes, backgrounds, fonts etc.) So whats the best approach to use shared css and js withouth

Symfony 2 - Working with assets

元气小坏坏 提交于 2019-11-27 00:10:48
问题 I need some tips on how to work with assets in Symfony 2. For example, do we have to always perform the assets:update every time an image is added ? I know Assetic take care of the management on css and javascript files but what about images? What would be the best practice for the front-end development with Symfony 2 ? How do you guys setup your css, images and js files in your app to make it easy to develop, deploy and change ? 回答1: Regarding images, if you added it into your public folder,

Pass a variable to an Assetic asset URL in Symfony2

二次信任 提交于 2019-11-26 21:32:44
问题 Is there a way to pass a variable to the Assetic method in templates {% stylesheets '@SomeExampleBundle/Resources/views/ SOMEVAR /css/*' %} <link rel="stylesheet" href="{{ asset_url }}" /> {% endstylesheets %} So what I want to do is pass SOMEVAR from the controller. 回答1: For now, I don't think it is possible at all. The reason behind this is that Assetic is run upfront to dump the assets, so it does not run the Twig template to compute the variable. This is probably the same if you do it in

Symfony2 - Assetic - css font icons

﹥>﹥吖頭↗ 提交于 2019-11-26 21:00:36
问题 How to include css font icon libraries istalled via composer in /vendor dir (fontawesome for example). Include: {% stylesheets filter='cssrewrite' '%kernel.root_dir%/../vendor/fortawesome/font-awesome/css/font-awesome.min.css' %} <link href="{{ asset_url }}" type="text/css" rel="stylesheet"/> {% endstylesheets %} But it does't rewrite font files url, it stays same, and icons wont load: src: url('../fonts/fontawesome-webfont.eot?v=4.0.3'); I know, we can't make urls poined outside of webroot,

With Assetic / Twig / Symfony2, can I define front end libraries?

风流意气都作罢 提交于 2019-11-26 15:56:39
问题 I'm using Symfony2, with Assetic and Twig. I have various frontend libraries - Backbone, jQuery, jQuery UI, and Bootstrap. Both Bootstrap and jQuery UI include CSS and JS files. Is there a way that I can define the resources they need to include (including dependencies), and then in Twig / Assetic just include all those resources in one tag? What I'd look to have is something like: // config.yml <!-- DOES NOT WORK --> assetic: resources: jquery: js: /filepath/to/jquery.js jquery_ui:

Combining Assetic Resources across inherited templates

强颜欢笑 提交于 2019-11-26 15:54:11
问题 We are building a new site using Symfony2, and Assetic looks very promising for resource management, in particular for combining and processing all js/css files together automatically. We wil have some resources that are used site wide, and some that are specific to particular pages. We will also be using a three tiered inherited approach to templates. Is there a way to combine the two concepts, i.e. to automatically add additional resources in inherited templates so that they are all output

Path of assets in CSS files in Symfony 2

百般思念 提交于 2019-11-26 14:52:44
Problem I have a CSS file with some paths in it (for images, fonts, etc.. url(..) ). My path structure is like this: ... +-src/ | +-MyCompany/ | +-MyBundle/ | +-Resources/ | +-assets/ | +-css/ | +-stylesheets... +-web/ | +-images/ | +-images... ... I want to reference my images in the stylesheet. First Solution I changed all paths in the CSS file to absolute paths. This is no solution, as the application should (and has to!) be working in a subdirectory, too. Second Solution Use Assetic with filter="cssrewrite" . So I changed all my paths in my CSS file to url("../../../../../../web/images

Path of assets in CSS files in Symfony 2

我是研究僧i 提交于 2019-11-26 04:04:29
问题 Problem I have a CSS file with some paths in it (for images, fonts, etc.. url(..) ). My path structure is like this: ... +-src/ | +-MyCompany/ | +-MyBundle/ | +-Resources/ | +-assets/ | +-css/ | +-stylesheets... +-web/ | +-images/ | +-images... ... I want to reference my images in the stylesheet. First Solution I changed all paths in the CSS file to absolute paths. This is no solution, as the application should (and has to!) be working in a subdirectory, too. Second Solution Use Assetic with