Download the PHP package jmikola/js-assets-helper-bundle without Composer
On this page you can find all versions of the php package jmikola/js-assets-helper-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download jmikola/js-assets-helper-bundle
More information about jmikola/js-assets-helper-bundle
Files in jmikola/js-assets-helper-bundle
Package js-assets-helper-bundle
Short Description Exposes the AssetsHelper service from Symfony2's templating component to JavaScript, allowing relative or absolute asset URI's to be generated client-side.
License MIT
Homepage https://github.com/jmikola/JmikolaJsAssetsHelperBundle
Informations about the package js-assets-helper-bundle
JmikolaJsAssetsHelperBundle
This bundle exposes the AssetsHelper service from Symfony2's templating component to JavaScript, which allows relative or absolute asset URI's to be generated client-side.
Compatibility
This bundle depends PR #2502, which is included in Symfony 2.0.5 and higher.
Configuration
If you do not configure the bundle explicitly, it will only expose the default
package defined in the templating
block of the FrameworkBundle configuration.
Named packages you wish to expose must be explicitly listed:
While an array of package names is the normal format, the configuration will also accept a scalar to expose a single package:
In these examples, "cloudfront" and "s3" correspond to named packages in the FrameworkBundle configuration. For example:
Additional information on configuring templating asset packages may be found in the FrameworkBundle docs.
Routing
The bundle defines one route to a dynamically generated JavaScript file. Ensure this route is including in your application's routing configuration:
Assets
The bundle includes a compiled JavaScript asset, which must be published to your
web/
directory:
Include the compiled and dynamic JavaScript in your applications template:
Usage
Once configured, the bundle creates a single AssetsHelper
global in JavaScript.
This is modeled after the PHP class from Symfony2's Templating component and
has the following methods:
Typically, you will want to use the getUrl()
method to generate asset paths.
Keep in mind that if you refer to a named package that has not been exposed, an
InvalidPackageError
will be thrown.
The following equivalent snippets demonstrate how AssetsHelper.getUrl()
compares to Symfony2's asset helper for Twig:
Development
Note: This bundle includes a static JavaScript asset, which is pre-compiled with Google's Closure Compiler. Any changes to the static JavaScript will require that you recompile the asset. For your convenience, you may want to install JMSGoogleClosureBundle and use the following command:
All versions of js-assets-helper-bundle with dependencies
symfony/dependency-injection Version >=2.0.5,<3.0-dev
symfony/framework-bundle Version ~2.0
symfony/twig-bundle Version ~2.0