troopers / asseticinjectorbundle Goto Github PK
View Code? Open in Web Editor NEWThe AsseticInjectorBundle allow you to automaticly include javascripts and stylesheets anywhere in your project
License: MIT License
The AsseticInjectorBundle allow you to automaticly include javascripts and stylesheets anywhere in your project
License: MIT License
If you don't specify the injector tag, it seems that it will load the "rest" of the resources that page don't load and is however defined in config file.
For now I resolved my issue by setting an injector="" attribute :
{% stylesheets filter='less, cssrewrite' injector=""
'@AppBundle/Resources/public/less/style.less'
%}
<link href="{{ asset_url }}" type="text/css" rel="stylesheet" media="screen" />
{% endstylesheets %}
Injection with tag like head or foot is great but do not fit every needs.
I think we should be able to inject assets by a more semantical name.
For example, if we want to include the "redactor" library, only in admin layout for example, we should be able to simply add the "redactor" string in the list of tags (by directly adding like the "normal" way but with the tag name (redactor)).
So technically, I think we have to authorize infinite depth in assetic injector configuration file to be able to include small libraries like redactor to huge library like bootstrap.
assetic_injector.json :
{
"require_all":
{
"stylesheets":
{
"bootstrap" :
{
"popover": "@MopaBootstrapBundle/Resources/public/bootstrap/less/bootstrap-popover.min.js",
"collapse": "@MopaBootstrapBundle/Resources/public/bootstrap/js/bootrstap-collapse.min.js"
}
},
"javascripts":
{
"bootstrap" :
{
"popover":
[
"@MopaBootstrapBundle/Resources/public/bootstrap/js/bootstrap-tooltip.min.js",
"@MopaBootstrapBundle/Resources/public/bootstrap/js/bootstrap-popover.min.js",
]
"collapse": "@MopaBootstrapBundle/Resources/public/bootstrap/js/bootstrap-collapse.min.js"
}
}
}
}
layout.html.twig :
{% stylesheets injector='bootstrap/popover, bootstrap/collapse' %}
<link rel="stylesheet" href="{{ asset_url }}">
{% endstylesheets %}
{% javascripts injector='bootstrap/popover, bootstrap/collapse' %}
<script type="text/javascript" src="{{ asset_url }}"></script>
{% endjavascripts %}
That don't have to change for 1 depth library inclusions :
assetic_injector.json :
{
"require_all":
{
"stylesheets":
{
"redactor": "@AvAwesomeShorcutsBundle/Resources/public/libs/redactor/redactor.css"
},
"javascripts":
{
"redactor":
[
"@AvAwesomeShorcutsBundle/Resources/public/libs/redactor/redactor.min.js",
"@AvAwesomeShorcutsBundle/Resources/public/libs/redactor/redactor.fr.js"
]
}
}
}
layout.html.twig :
{% stylesheets injector='redactor' %}
<link rel="stylesheet" href="{{ asset_url }}">
{% endstylesheets %}
{% javascripts injector='redactor' %}
<script type="text/javascript" src="{{ asset_url }}"></script>
{% endjavascripts %}
The next step will to add directly the name near line as I said before :
doing the stuff like this in layout.html.twig :
{% stylesheets injector='redactor' %}
<link rel="stylesheet" href="{{ asset_url }}">
{% endstylesheets %}
{% javascripts
'@bootrstrap/popover'
'@bootrstrap/collapse'
%}
<script type="text/javascript" src="{{ asset_url }}"></script>
{% endjavascripts %}
To be continued
Hello,
I have this situation :
template.html.twig :
{% javascripts injector="foot"
'@AcmeBundle/Resources/public/js/arandomjqueryplugin.js'
%}
<script type="text/javascript" src="{{ asset_url }}"></script>
{% endjavascripts %}
assetic_injector.json:
{
"require_all":
{
"javascripts":
{
"foot":
[
"@ThemeBundle/Resources/public/js/jquery.min.js",
]
}
}
}
The jQuery file is injected after the plugin and triggers an error.
Is it already possible to change this order ?
If not, can we use a static keyword like "pre-" or "post-" in injector tags to manually indicate the order we want ?
Hi,
I've added a dependancy to this package in one of my bundles. (https://packagist.org/packages/concerto-cms/admin-bundle). But your package is not being installed because it has no stable version.
Could you create a release with a version number for this package ? This will give the package a stable state on packagist and allow bundles to refer to this package.
[Symfony\Component\DependencyInjection\Exception\ParameterNotFoundException]
The service "assetic.twig_extension" has a dependency on a non-existent parameter "assetic.use_controller".
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.