Manifest Asset Bundle
This bundle provides Twig helper for generating urls for static public assets., (*1)
It reads information from simple JSON config file. There is an example file in
manifest.json, (*2)
Usage
Bundle provides two Twig functions - manifestAsset and manifestAssetInline., (*3)
mainfestAsset takes 2 parameters:, (*4)
- asset url in format @BundleName:path/to/asset or namespaced path @BundleName/path/to/asset
- optional array with options
- for now only option is: "absolute" => if true function returns absolute URIs
Example usage:, (*5)
<link href="{{ manifestAsset('@AppBundle:css/bundles/home.css') }}" rel="stylesheet" type="text/css">
manifestAssetInline takes 1 parameter:, (*6)
- asset url in format @BundleName:path/to/asset or namespaced path @BundleName/path/to/asset
It returns the file content of the asset., (*7)
Example usage:, (*8)
<style>{{ manifestAssetInline('@AppBundle:css/bundles/home.css') }}</style>
Using custom Twig namespaces
First, you need to register your Twig namespace:, (*9)
twig:
paths:
'%kernel.project_dir%/src/App/Resources': SomeTwigNamepace
Then, you can use :, (*10)
<style>{{ manifestAsset('@SomeTwigNamepace/css/home.css') }}</style>
<style>{{ manifestAssetInline('@SomeTwigNamepace/js/home.js') }}</style>
Note: Twig namespace references does not contain separator :
like bundles. See this link for more details., (*11)
Running tests and linter
For running tests and linter, there is a complete docker enviroment with php and all required tools.
To setup environment use:, (*12)
bin/dev/docker-compose build
bin/dev/composer install
To run tests (after environment is built):, (*13)
bin/dev/composer test
To run linter:, (*14)
bin/dev/phpcsfixer fix --dry-run .
To automaticaly fix coding standards, just ommit --dry-run
parameter., (*15)
Credits
Copyright (C) 2017 Trikoder, (*16)
Authors: Alen Pokos, Damir Brekalo, Krešo Kunjas., (*17)
Contributors: Branimir Đurek, (*18)
License
Package is licensed under MIT License, (*19)