-
-
Notifications
You must be signed in to change notification settings - Fork 5.2k
[2.7] Update Twig docs for asset features #5574
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -111,7 +111,8 @@ asset | |
|
||
Returns a public path to ``path``, which takes into account the base path | ||
set for the package and the URL path. More information in | ||
:ref:`book-templating-assets`. For asset versioning, see :ref:`reference-framework-assets-version`. | ||
:ref:`book-templating-assets`. For asset versioning, see | ||
:ref:`reference-framework-assets-version`. | ||
|
||
assets_version | ||
~~~~~~~~~~~~~~ | ||
|
@@ -362,8 +363,8 @@ information in :ref:`book-templating-pages`. | |
absolute_url | ||
~~~~~~~~~~~~ | ||
|
||
.. versionadded:: 2.6 | ||
The ``absolute_url`` function was introduced in Symfony 2.7 | ||
.. versionadded:: 2.7 | ||
The ``absolute_url()`` function was introduced in Symfony 2.7. | ||
|
||
.. code-block:: jinja | ||
|
||
|
@@ -372,18 +373,23 @@ absolute_url | |
``path`` | ||
**type**: ``string`` | ||
|
||
Returns the absolute URL for the given absolute path. This is useful to convert | ||
an existing path: | ||
Returns the absolute URL from the passed relative path. For example, assume | ||
you're on the following page in your app: | ||
``http://example.com/products/hover-board``. | ||
|
||
.. code-block:: jinja | ||
|
||
{{ absolute_url(asset(path)) }} | ||
{{ absolute_url('/human.txt') }} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we could also add the current URL here: {# assume the current URL is http://example.com/products/hover-board #} There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Doing it twice seems a bit duplicated to me. I've not included it in the PR, but feel free to make this change during merging if you feel it makes things better. |
||
{# http://example.com/human.txt #} | ||
|
||
{{ absolute_url('products_icon.png') }} | ||
{# http://example.com/products/products_icon.png #} | ||
|
||
relative_path | ||
~~~~~~~~~~~~~ | ||
|
||
.. versionadded:: 2.6 | ||
The ``relative_path`` function was introduced in Symfony 2.7 | ||
.. versionadded:: 2.7 | ||
The ``relative_path()`` function was introduced in Symfony 2.7. | ||
|
||
.. code-block:: jinja | ||
|
||
|
@@ -392,10 +398,17 @@ relative_path | |
``path`` | ||
**type**: ``string`` | ||
|
||
Returns a relative path for the given absolute path (based on the current | ||
request path). For instance, if the current path is | ||
``/article/news/welcome.html``, the relative path for ``/article/image.png`` is | ||
``../images.png``. | ||
Returns the relative path from the passed absolute URL. For example, assume | ||
you're on the following page in your app: | ||
``http://example.com/products/hover-board``. | ||
|
||
.. code-block:: jinja | ||
|
||
{{ relative_path('http://example.com/human.txt') }} | ||
{# ../human.txt #} | ||
|
||
{{ relative_path('http://example.com/products/products_icon.png') }} | ||
{# products_icon.png #} | ||
|
||
expression | ||
~~~~~~~~~~ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does it make sense to add a warning that this is not supported? Otherwise, people who use old links might get lost as the anchor wouldn't match anymore.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would say yes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you mean adding an admonition about this in the docs? I don't like that, it'll put completely unrelated text in the documentation (also, anyone linking to this currently wouldn't read the warning anyways)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Honestly, I cannot remember anymore what I had in mind back then.