From 412c88c815c4b0941f8c992300c0d905fedd7ae2 Mon Sep 17 00:00:00 2001 From: Alexpts Date: Sun, 30 Oct 2016 19:53:54 +0300 Subject: [PATCH 1/4] Component has only one helper in real --- components/templating.rst | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/components/templating.rst b/components/templating.rst index 6a5f7f52b48..816d376f1f2 100644 --- a/components/templating.rst +++ b/components/templating.rst @@ -139,9 +139,8 @@ Helpers The Templating component can be easily extended via helpers. Helpers are PHP objects that provide features useful in a template context. The component has -2 built-in helpers: +a built-in helper: -* :doc:`/components/templating/assetshelper` * :doc:`/components/templating/slotshelper` Before you can use these helpers, you need to register them using From 48ba46487081deeca85926c2d5360b11ca965182 Mon Sep 17 00:00:00 2001 From: Alexpts Date: Tue, 1 Nov 2016 13:25:47 +0300 Subject: [PATCH 2/4] fix typo --- components/templating.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/templating.rst b/components/templating.rst index 816d376f1f2..ced72edd3ea 100644 --- a/components/templating.rst +++ b/components/templating.rst @@ -139,7 +139,7 @@ Helpers The Templating component can be easily extended via helpers. Helpers are PHP objects that provide features useful in a template context. The component has -a built-in helper: +one built-in helper: * :doc:`/components/templating/slotshelper` From 16984e7c09d1fb3fc0c866da9edaafc1d6d52dd9 Mon Sep 17 00:00:00 2001 From: Alexpts Date: Tue, 1 Nov 2016 20:09:33 +0300 Subject: [PATCH 3/4] Delete assetshelper.rst --- components/templating/assetshelper.rst | 131 ------------------------- 1 file changed, 131 deletions(-) delete mode 100644 components/templating/assetshelper.rst diff --git a/components/templating/assetshelper.rst b/components/templating/assetshelper.rst deleted file mode 100644 index 837b94255bc..00000000000 --- a/components/templating/assetshelper.rst +++ /dev/null @@ -1,131 +0,0 @@ -.. index:: - single: Templating Helpers; Assets Helper - -Assets Helper -============= - -The assets helper's main purpose is to make your application more portable by -generating asset paths: - -.. code-block:: html+php - - - - - -The assets helper can then be configured to render paths to a CDN or modify -the paths in case your assets live in a sub-directory of your host (e.g. ``http://example.com/app``). - -Configure Paths ---------------- - -By default, the assets helper will prefix all paths with a slash. You can -configure this by passing a base assets path as the first argument of the -constructor:: - - use Symfony\Component\Templating\Helper\AssetsHelper; - - // ... - $templateEngine->set(new AssetsHelper('/foo/bar')); - -Now, if you use the helper, everything will be prefixed with ``/foo/bar``: - -.. code-block:: html+php - - - - -Absolute Urls -------------- - -You can also specify a URL to use in the second parameter of the constructor:: - - // ... - $templateEngine->set(new AssetsHelper(null, 'http://cdn.example.com/')); - -Now URLs are rendered like ``http://cdn.example.com/images/logo.png``. - -You can also use the third argument of the helper to force an absolute URL: - -.. code-block:: html+php - - - - -.. note:: - - If you already set a URL in the constructor, using the third argument of - ``getUrl`` will not affect the generated URL. - -Versioning ----------- - -To avoid using the cached resource after updating the old resource, you can -use versions which you bump every time you release a new project. The version -can be specified in the third argument:: - - // ... - $templateEngine->set(new AssetsHelper(null, null, '328rad75')); - -Now, every URL is suffixed with ``?328rad75``. If you want to have a different -format, you can specify the new format in fourth argument. It's a string that -is used in :phpfunction:`sprintf`. The first argument is the path and the -second is the version. For instance, ``%s?v=%s`` will be rendered as -``/images/logo.png?v=328rad75``. - -You can also generate a versioned URL on an asset-by-asset basis using the -fourth argument of the helper: - -.. code-block:: html+php - - - - -Multiple Packages ------------------ - -Asset path generation is handled internally by packages. The component provides -2 packages by default: - -* :class:`Symfony\\Component\\Templating\\Asset\\PathPackage` -* :class:`Symfony\\Component\\Templating\\Asset\\UrlPackage` - -You can also use multiple packages:: - - use Symfony\Component\Templating\Asset\PathPackage; - - // ... - $templateEngine->set(new AssetsHelper()); - - $templateEngine->get('assets')->addPackage('images', new PathPackage('/images/')); - $templateEngine->get('assets')->addPackage('scripts', new PathPackage('/scripts/')); - -This will setup the assets helper with 3 packages: the default package which -defaults to ``/`` (set by the constructor), the images package which prefixes -it with ``/images/`` and the scripts package which prefixes it with -``/scripts/``. - -If you want to set another default package, you can use -:method:`Symfony\\Component\\Templating\\Helper\\AssetsHelper::setDefaultPackage`. - -You can specify which package you want to use in the second argument of -:method:`Symfony\\Component\\Templating\\Helper\\AssetsHelper::getUrl`: - -.. code-block:: html+php - - - - -Custom Packages ---------------- - -You can create your own package by extending -:class:`Symfony\\Component\\Templating\\Asset\\Package`. From 8e9c615f8a7d0072469d4d01601c53e6c576c2a8 Mon Sep 17 00:00:00 2001 From: Alexpts Date: Tue, 1 Nov 2016 20:16:12 +0300 Subject: [PATCH 4/4] Remove deprecated example --- components/templating.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/templating.rst b/components/templating.rst index ced72edd3ea..6614ff00eac 100644 --- a/components/templating.rst +++ b/components/templating.rst @@ -146,10 +146,10 @@ one built-in helper: Before you can use these helpers, you need to register them using :method:`Symfony\\Component\\Templating\\PhpEngine::set`:: - use Symfony\Component\Templating\Helper\AssetsHelper; + use Symfony\Component\Templating\Helper\SlotsHelper; // ... - $templating->set(new AssetsHelper()); + $templating->set(new SlotsHelper()); Custom Helpers ~~~~~~~~~~~~~~