This bundle provides Twig helper for generating urls for static public assets.
It reads information from simple JSON config file. There is an example file in manifest.json
Bundle provides two Twig functions - manifestAsset and manifestAssetInline.
mainfestAsset takes 2 parameters:
- 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:
<link href="{{ manifestAsset('@AppBundle:css/bundles/home.css') }}" rel="stylesheet" type="text/css">
<script async src="{{ manifestAsset('@AppBundle:js/home.js') }}"></script>
manifestAssetInline takes 1 parameter:
- asset url in format @BundleName:path/to/asset or namespaced path @BundleName/path/to/asset
It returns the file content of the asset.
Example usage:
<style>{{ manifestAssetInline('@AppBundle:css/bundles/home.css') }}</style>
First, you need to register your Twig namespace:
twig:
paths:
'%kernel.project_dir%/src/App/Resources': SomeTwigNamepace
Then, you can use :
<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.
For running tests and linter, there is a complete docker enviroment with php and all required tools. To setup environment use:
bin/dev/docker-compose build
bin/dev/composer install
To run tests (after environment is built):
bin/dev/composer test
To run linter:
bin/dev/phpcsfixer fix --dry-run .
To automaticaly fix coding standards, just ommit --dry-run
parameter.
Copyright (C) 2017 Trikoder
Authors: Alen Pokos, Damir Brekalo, Krešo Kunjas.
Contributors: Branimir Đurek
Package is licensed under MIT License