Download the PHP package pine3ree/pine3ree-plates-resolvers without Composer
On this page you can find all versions of the php package pine3ree/pine3ree-plates-resolvers. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package pine3ree-plates-resolvers
pine3ree-plates-resolvers
This package provides a couple of template resolvers with cache support for the Plates engine:
-
NameAndFolderResolveTemplatePath
is the same default Plates resolver, but with cache enabled ReverseFallbackResolveTemplatePath
is a resolver that works in the opposite way: first, if defined, the global template directory is searched and then the template folder is searched
Install
This package requires PHP 7.4 ~ 8.2
. You can install it via composer:
NameAndFolderResolveTemplatePath
Works the same way as the default Plates template-path resolver, but with added cache support for resolved templates.
The internal cache stores and returns by name those template paths that have
already been positively resolved, thus avoiding calling $name->getPath()
repeatedly on the same template. The internal cache is enabled including the
CacheableResolveTemplatePathTrait trait
in this package implementing methods
of the CacheableResolveTemplatePathInterface
This is useful in cases when you use partials like sorting-table-headers links
or multiple paginators several times on the same page. At the same time it also
provides long term caching for async environments like Swoole
ReverseFallbackResolveTemplatePath
This resolver acts in the opposite way of the default plates resolver
When a template is rendered with a folder specification (Plates ::
notation),
the search starts at the default template directory (if defined) but with an
added sub-folder matching the folder specification, e.g.:
Furthermore, when a template name is provided without a folder specification but contains the path separator "/", then a folder will be assigned using the first segment. Therefore the previous example applies also for the following simpler render call:
In both cases the "partial" folder must have been defined in the engine's configuration.
This can be useful in modular application, where we want each module templates to be close to the source code. In those cases we set a folder for each module template. When we reuse the same module in other applications it will works right away. Then, we will use the default "application" templates directory t0 customize/override the default templates provided by each module.
Example:
Given the following application directory structure
The following code applies:
The url-path "/" segment notation is recommended since it shows the template path relative to the global templates directory, while the standard folder notation could trick into believeing that global directory templates are not being used.