GithubHelp home page GithubHelp logo

delormejonathan / asseticinjectorbundle Goto Github PK

View Code? Open in Web Editor NEW

This project forked from troopers/asseticinjectorbundle

0.0 2.0 0.0 22 KB

The AsseticInjectorBundle allow you to automaticly include javascripts and stylesheets anywhere in your project

License: MIT License

PHP 100.00%

asseticinjectorbundle's Introduction

Troopers

SensioLabsInsight

=============

AsseticInjectorBundle

The AsseticInjectorBundle allows you to automatically include javascripts and stylesheets anywhere in your project. This bundle will scan every registered bundles and search for an assetic_injector.json file. From this file, the injector will collect the resources and inject them into the assetic engine. To include them, you have to define the tag (foot, head, custom, actually the one you choose) and add the tag in the wanted assetic block.

Install

With Composer :

Add this line in your composer.json file :

"troopers/assetic-injector-bundle": "~1.0"

Declare the bundle in your AppKernel.php:

public function registerBundles() {
    $bundles = array(
        [...]
        new Troopers\AsseticInjectorBundle\TroopersAsseticInjectorBundle(),
        [...]

Then declare an assetic_injector.json in the Resource/config folder of your application or bundle:

{
    "require_all":
    {
        "javascripts":
        {
            "foot": "@MyBundle/Resources/public/js/myscript.js"
        },
        "stylesheets":
        {
            "head": "@MyBundle/Resources/public/css/mystyle.css"
        }
    }
}

Now, to include the resources, just add the name of the resource tag (foot, head etc) in your assetic's block.

For example, this code ...

    {% javascripts injector="head"
        '@MyAcmeDemoBundle/Resources/public/jsloremipsumdolorsitamet.js'
     %}
    <script type="text/javascript" src="{{ asset_url }}"></script>
    {% endjavascripts %}

will inject assetic_injector.json and regarding to the example wrote before equals to :

    {% javascripts injector="head"
        '@MyAcmeDemoBundle/Resources/public/jsloremipsumdolorsitamet.js'
        '@MyBundle/Resources/public/js/myscript.js'
     %}
    <script type="text/javascript" src="{{ asset_url }}"></script>
    {% endjavascripts %}

So, no more needs to include javascript or stylesheets from assetic injector's ready bundles ! Just add the tag and here we are !

Enjoy !

asseticinjectorbundle's People

Contributors

bitdeli-chef avatar lenybernard avatar paulandrieux avatar webberig avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.