Download the PHP package unprefix/template-loader without Composer

On this page you can find all versions of the php package unprefix/template-loader. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package template-loader

Build Status codecov

WordPress Template Loader

A simple hookable template loader for WordPress. Allow you to load templates in chain from child to plugin.

This is not for the WordPress templates in the form of "name-slug.php" with fallback to name.php. Indeed this is a loader to build a basic data injection for views (templates).

Requirements

Php >= 5.6.x

Examples

The TemplateLoader\Loader class make use of the Fluent interface, so it's possible to concatenate the calls to ask the instance to do the things.

The class make use of WordPress function locate_template to locate the template file within the child and parent theme.

If you use the library within a plugin it's possible to define a fallback template part file path. As the name fallback says the file will be loaded only in case nothing is found into the previous locations.

Since WordPress function locate_template allow to pass an array along a string, we can do the same by passing an array of template paths to the method usingTemplate.

Data Type

The data type used to inject values into the template is a class named TemplateLoader\ModelInterface. ModelInterface doesn't declare any method. It's just a way to ensure the correct type of data is passed into the template loader.

This way we can extends the interface to create our own contracts based on the specific view.

Hooks

The render method, perform some filters that allow third party code to hook into the data and template to be modified before the template file is loaded.

There are two filter: tmploader_template_engine_data that is generic and pass the $data value and the slug property.

The second one is similar but the filter name include the slug template: "tmploader_template_engine_data_{$this->slug}". This in case you don't want or need to write conditional statements to know which is the current processing template.

Performances

Since it's usually to call the same view in different portion of the same page, so whitin the same http request, to prevent to access multiple time to the file system only to know where the file template is located, we defined an internal collection that can be used to store the template file paths.

The second time we try to ask the same template, we'll not perform any additional filesystem access in order to load the template file. This improve speed for multiple calls. Also since we don't create a strict relation betwee the template and the data to inject, we can pass every time a different data value.

So, just to clarify with an example, during the same call we can instantiate the loader once and than ask to load the same template multiple times with different data values.

The second time we call the render method we had changed only the data used within the template since we have stored the template path related with the slug of the template. In this case template_slug.

Avoiding unnecessary filesystem access that we know are slows.


All versions of template-loader with dependencies

PHP Build Version
Package Version
No informations.
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package unprefix/template-loader contains the following files

Loading the files please wait ....