Download the PHP package smoya/asset-management-bundle without Composer
On this page you can find all versions of the php package smoya/asset-management-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download smoya/asset-management-bundle
More information about smoya/asset-management-bundle
Files in smoya/asset-management-bundle
Package asset-management-bundle
Short Description Symfony2 bundle that provides an easy way for manage assetic packages inclusion in Twig Templates.
License MIT
Homepage https://github.com/smoya/AssetManagementBundle
Informations about the package asset-management-bundle
AssetManagementBundle
An Asset Management Bundle for Symfony2
TODO:
- Improve README Doc
- More functions
- Tests
- etc
This bundle provides an easy way for manage assetic packages inclusion in Twig Templates. Of course, We need to have previously installed the Assetic library .
This bundle allows you to print the code that includes assets (javascript and css) there in the place where desired. For example, after loading javascript jquery libraries already loaded at the end of the html code.
In example, this is posible:
Template 1 (Not extends from a base template):
Base Template:
Getting as a result:
Installation
Add this entry to the deps
file
Register the bundle into your application Kernel
// app/AppKernel.php
public function registerBundles()
{
return array(
//..
new Smoya\AssetManagementBundle\SmoyaAssetManagementBundle(),
//..
);
}
In 2.1*
Smoya\Bundle\AssetManagementBundle\SmoyaAssetManagementBundle()
Now update vendors:
Now, we need to add this entry to the autoloader:
Use
First of all, we need to set the packages need to include. The guys of Sonata have a post with an example here.
Imagine the following case:
We have 3 Templates
-
::base.html.twig
-
index.html.twig
- widget.html.twig
The problem and a solution:
When using Twig render, and if the rendered template contains javascript, it will print where the've called. This is a problem if you are rendering before loading javascripts, especially if the code requires other libraries (eg jQuery).
For this we use the features of Twig adding this bundle as follows:
-
::base.html.twig
-
index.html.twig
- widget.html.twig
Options and parameters
Add Assets:
The parameters:
- 1: ASSETS Array/Scalar An array of assets or a single asset. example: ['assetic/foo.js', 'assetic/bar.js']
- 2: FORMAT String The format of the assets (js, css, inline_js or inline_css)
- 3: ATTR Array Optional Associative array of attributes for the inclusion html tag. example for a css asset: {'media': 'screen'}
Print assets:
The parameters:
- 1: ASSETS String Optional The format of the assets to print.
All versions of asset-management-bundle with dependencies
symfony/framework-bundle Version >=2.0.0
twig/twig Version >=1.9.1,<2.0-dev