Download the PHP package irishdan/js-settings-bundle without Composer
On this page you can find all versions of the php package irishdan/js-settings-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download irishdan/js-settings-bundle
More information about irishdan/js-settings-bundle
Files in irishdan/js-settings-bundle
Package js-settings-bundle
Short Description A bundle for injecting data as javascript into a page
License MIT
Homepage https://github.com/irishdan/JsSettingsBundle
Informations about the package js-settings-bundle
JsSettingsBundle
This bundle provides a service and a twig extension for easily injecting data into a webpage as a javascript object.
1: Installation
Install with composer.
Step 2: Enable the Bundle
Enable the bundle by adding it to the list of registered bundles
in the app/AppKernel.php
file of your project:
Import the service definition in your config.yml file imports:
3: Configuration
No configuration is needed. Some is available.
In config.yml you can add:
object_name: By default the Javascript object it Called 'Symfony'. You can change the use 'JsData', by using the configuration above.
defaults: Default values are added to the javascript object by default and are always available.
4: Usage
The bundle provides a single service 'js_settings.settings' to add data and remove data from the javascript object.
To add variables simple pass in a key value pair like so:
Or, use pushData to push the data into an array.
To inject the javascript object into the page, simply add the following twig function to your twig template
All versions of js-settings-bundle with dependencies
symfony/framework-bundle Version ~3.0|~4.0
symfony/property-access Version ~3.4|~4.0