mirror of
https://github.com/twigphp/Twig.git
synced 2026-09-04 22:47:21 +00:00
added missing docs
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
``data_uri``
|
||||
============
|
||||
|
||||
.. versionadded:: 2.12
|
||||
The ``data_uri`` filter was added in Twig 2.12.
|
||||
|
||||
The ``data_uri`` filter generates a URL using the data scheme as defined in RFC
|
||||
2397:
|
||||
|
||||
.. code-block:: twig
|
||||
|
||||
{{ image_data|data_uri }}
|
||||
|
||||
{{ source('path_to_image')|data_uri }}
|
||||
|
||||
{# force the mime type, disable the guessing of the mime type #}
|
||||
{{ image_data|data_uri(mime="image/svg") }}
|
||||
|
||||
{# also works with plain text #}
|
||||
{{ '<b>foobar</b>'|data_uri(mime="text/html") }}
|
||||
|
||||
{# add some extra parameters #}
|
||||
{{ '<b>foobar</b>'|data_uri(mime="text/html", parameters={charset: "ascii"}) }}
|
||||
|
||||
.. note::
|
||||
|
||||
The ``data_uri`` filter is part of the ``HtmlExtension`` which is not
|
||||
enabled by default; you must add it explicitly on the Twig environment::
|
||||
|
||||
use Twig\Extension\HtmlExtension;
|
||||
|
||||
$twig = new \Twig\Environment(...);
|
||||
$twig->addExtension(new HtmlExtension());
|
||||
|
||||
.. note::
|
||||
|
||||
The filter does not perform any length validation on purpose (limits depends
|
||||
on the usage context), validation should be done before calling this filter.
|
||||
|
||||
Arguments
|
||||
---------
|
||||
|
||||
* ``mime``: The mime type
|
||||
* ``parameters``: An array of parameters
|
||||
@@ -9,6 +9,7 @@ Filters
|
||||
capitalize
|
||||
column
|
||||
convert_encoding
|
||||
data_uri
|
||||
date
|
||||
date_modify
|
||||
default
|
||||
|
||||
Reference in New Issue
Block a user