Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Added "How to Use a Custom Version Strategy for Assets" #7141

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 12 commits into from
Dec 12, 2016
Prev Previous commit
Next Next commit
Fixed a rebase error
  • Loading branch information
javiereguiluz committed Nov 15, 2016
commit ab8fa54c5e0518e1ab82c543a0a378247c245fd7
75 changes: 0 additions & 75 deletions 75 reference/configuration/framework.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1256,81 +1256,6 @@ templating loaders. Templating loaders are used to find and load templates
from a resource (e.g. a filesystem or database). Templating loaders must
implement :class:`Symfony\\Component\\Templating\\Loader\\LoaderInterface`.

.. _reference-framework-assets-packages:

packages
........

You can group assets into packages, to specify different base URLs for them:

.. configuration-block::

.. code-block:: yaml

# app/config/config.yml
framework:
# ...
templating:
packages:
avatars:
base_urls: 'http://static_cdn.example.com/avatars'

.. code-block:: xml

<!-- app/config/config.xml -->
<?xml version="1.0" encoding="UTF-8" ?>
<container xmlns="http://symfony.com/schema/dic/services"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:framework="http://symfony.com/schema/dic/symfony"
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd
http://symfony.com/schema/dic/symfony http://symfony.com/schema/dic/symfony/symfony-1.0.xsd">

<framework:config>

<framework:templating>

<framework:package
name="avatars"
base-url="http://static_cdn.example.com/avatars">

</framework:templating>

</framework:config>
</container>

.. code-block:: php

// app/config/config.php
$container->loadFromExtension('framework', array(
// ...
'templating' => array(
'packages' => array(
'avatars' => array(
'base_urls' => 'http://static_cdn.example.com/avatars',
),
),
),
));

Now you can use the ``avatars`` package in your templates:

.. configuration-block:: php

.. code-block:: html+jinja

<img src="{{ asset('...', 'avatars') }}">

.. code-block:: html+php

<img src="<?php echo $view['assets']->getUrl('...', 'avatars') ?>">

Each package can configure the following options:

* :ref:`base_urls <reference-templating-base-urls>`
* :ref:`version <reference-framework-assets-version>`
* :ref:`version_format <reference-templating-version-format>`

>>>>>>> Cookbook entry: Asset - Custom Version Strategy
translator
~~~~~~~~~~

Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.