2017 © Pedro Peláez
 

library dynamic-asset-include-bundle

Dynamically include assets.

image

rvanginneken/dynamic-asset-include-bundle

Dynamically include assets.

  • Friday, November 17, 2017
  • by rvanginneken
  • Repository
  • 1 Watchers
  • 1 Stars
  • 31 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 4 Versions
  • 0 % Grown

The README.md

AssetBundle

The AssetBundle makes it easy to include assets at any point in your twig files and render it at the end of the <head> and <body> tags in the page. No blocks needed. Stylesheets are printed inline and all results are cached in production, following Symfony's cache.app settings., (*1)

In debug mode, actual assets are served. In no-debug mode, files are copied to web/asset_cache with unique naming. The directory is automatically cleared with the cache:clear command. Using unique file names guarantees browser cache busting when the application cache is cleared., (*2)

Installation

Require the bundle with composer:, (*3)

    $ composer require rvanginneken/asset-bundle

Enable the bundle in the AppKernel:, (*4)

    public function registerBundles()
    {
        $bundles = [
            // ...
            new RVanGinneken\AssetBundle\RVanGinnekenAssetBundle(),
            // ...
        ];
    }

Ignore the asset cache directory (used to bust browser cache). Put the following in your .gitignore:, (*5)

    # ..
    /web/asset_cache/
    # ..

That's it., (*6)

Usage

Note: priorities are optional and are only added to these examples to show their availability., (*7)

Include a stylesheet:, (*8)

    {% asset 'css_file', 'css/hello_world.css', 0 %}

Include inline style:, (*9)

    {%- set inline_style_hello_world -%}
        <style>
            body {
                background-color: lightblue;
            }
        </style>
    {%- endset -%}

    {% asset 'css', inline_style_hello_world, 0 %}

Include a javascript file:, (*10)

    {% asset 'javascript_file', 'js/hello_world.js', 0 %}

Include inline javascript:, (*11)

    {%- set inline_javascript_hello_world -%}
        <script type="text/javascript">
            console.log('Hello world!');
        </script>
    {%- endset -%}

    {% asset 'javascript', inline_javascript_hello_world, 0 %}

The Versions

17/11 2017

dev-master

9999999-dev

Dynamically include assets.

  Sources   Download

MIT

The Requires

 

by Roy Van Ginneken

twig cache bundle symfony asset include

17/11 2017

1.2.0

1.2.0.0

Dynamically include assets.

  Sources   Download

MIT

The Requires

 

by Roy Van Ginneken

twig cache bundle symfony asset include

17/11 2017

1.1.0

1.1.0.0

Dynamically include assets.

  Sources   Download

MIT

The Requires

 

by Roy Van Ginneken

twig cache bundle symfony asset include

14/11 2017

1.0.0

1.0.0.0

Dynamically include assets.

  Sources   Download

MIT

The Requires

 

by Roy Van Ginneken

cache bundle symfony asset