Permalink
Browse files

feature #3683 [TwigBundle] Add documentation about generating absolut…

…e URL with the asset function (romainneutron)

This PR was merged into the master branch.

Discussion
----------

[TwigBundle] Add documentation about generating absolute URL with the asset function

| Q             | A
| ------------- | ---
| Doc fix?      | no
| New docs?     | yes (symfony/symfony#10451)
| Applies to    | 2.5+

Commits
-------

bd947c7 [TwigBundle] Add documentation about generating absolute URL with the asset function
  • Loading branch information...
weaverryan committed Mar 18, 2014
2 parents fc1576a + bd947c7 commit 842fd303545ab3e325ed83d94ef5800fbda6d29c
Showing with 104 additions and 71 deletions.
  1. +16 −0 book/templating.rst
  2. +17 −0 components/templating/helpers/assetshelper.rst
  3. +71 −71 reference/twig_reference.rst
View
@@ -991,6 +991,22 @@ assets won't be cached when deployed. For example, ``/images/logo.png`` might
look like ``/images/logo.png?v2``. For more information, see the :ref:`ref-framework-assets-version`
configuration option.
.. versionadded:: 2.5
Absolute URLs for assets were introduced in Symfony 2.5.
If you need absolute URLs for assets, you can set the third argument (or the
``absolute`` argument) to ``true``:
.. configuration-block::
.. code-block:: html+jinja
<img src="{{ asset('images/logo.png', absolute=true) }}" alt="Symfony!" />
.. code-block:: html+php
<img src="<?php echo $view['assets']->getUrl('images/logo.png', null, true) ?>" alt="Symfony!" />
.. index::
single: Templating; Including stylesheets and JavaScripts
single: Stylesheets; Including stylesheets
@@ -47,6 +47,23 @@ You can also specify a URL to use in the second parameter of the constructor::
Now URLs are rendered like ``http://cdn.example.com/images/logo.png``.
.. versionadded:: 2.5
Absolute URLs for assets were introduced in Symfony 2.5.
You can also use the third argument of the helper to force an absolute URL:
.. code-block:: html+php
<img src="<?php echo $view['assets']->getUrl('images/logo.png', null, true) ?>">
<!-- renders as:
<img src="http://yourwebsite.com/foo/bar/images/logo.png">
-->
.. note::
If you already set a URL in the constructor, using the third argument of
``getUrl`` will not affect the generated URL.
Versioning
----------
Oops, something went wrong.

0 comments on commit 842fd30

Please sign in to comment.