Download the PHP package hokoo/templater without Composer

On this page you can find all versions of the php package hokoo/templater. 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 templater

Anatomy: a templater for PHP

Latest stable version CI quality gates PHP requirement

HTML Templater for PHP.

Lightweight, simple but powerful templater for rendering HTML templates in PHP.

I believe that you'd like to

Table of Contents

How rendering works

Inserted data is opaque and is never parsed as template source. The empty-data bypass and the different detached-block behavior are part of the public contract, not optimizations.

Requirements

PHP 8.0 and later.

Installation

Getting Started

Here are some examples of how to use the templater.

:a: Tags

Example:

PHP code:

The result will be:

Read more theory about Tags Tag - a point in the template where you can insert a value. Tag should be considered as a placeholder for a value. In the Anatomy's paradigm, the 'tag' is only entity that can be replaced with a value. The tag is a string that starts with `{{` and ends with `}}`. Regular tags render raw values. Use `{{tag|e}}` for user-controlled HTML text or quoted HTML attribute values. Attribute placeholders must always be enclosed in quotes. See [Rendering contract and escaping](#rendering-contract-and-escaping). So, in the example above, the `{{title}}` and `{{content}}` are tags. Let's render the template with the values.

:a: Predefined tags

Example:

PHP code:

The result will be:

Read more theory about Predefined Tags Predefined tags are tags that can render only values predefined by the template. Predefined tag's modifier can only accept an integer value as index of one of the predefined values (starting from 0). Any invalid modifier value (non-integer or integer that points beyond of the array) will be considered as 0. A missing, negative, or out-of-range modifier is also considered as 0. The default values' delimiter is `|`. You can change it by setting the `delimiter` property of the tag.

:a: Blocks & Containers

Example:

PHP code:

The result will be:

Read more theory about Blocks & Containers Blocks are a way to have a component-like structure in the template. You can consider blocks as a template inside a template. You can define as many blocks as you want and render them in any order. Each block definition must have a unique name. The same definition can be rendered repeatedly and recursively through nested containers. You can put one block into another block. This is how you can create a nested structure without any restrictions on the depth of nesting.

:a: Detached mode

Since we consider blocks as an almost independent template, you can use blocks out of context of the main template.

Suppose, you need to render the "article" block from the template above in a different place. Great, there's no need to duplicate the block's code. Just render the block separately.

The result would be:

Rendering contract and escaping

Calling render( $template, [] ) intentionally returns the original template without replacing tags, extracting blocks, or validating its syntax. Detached blocks are different: renderBlock() can render a hard-coded block with its default empty data array.

{{tag}} remains raw for version 4 compatibility. Use {{tag|e}} for HTML escaping:

HTML escaping is not a substitute for JavaScript, CSS, or URL-specific encoding. In HTML attributes, always put an escaped placeholder inside quotes, for example data-label="{{label|e}}"; never use an unquoted placeholder. The complete value, error, block grammar, and security contracts are documented in Anatomy template language.

Back compatibility

Version 3 compatibility is deprecated as of 4.2 and is planned for removal in version 5. It receives compatibility fixes during the version 4 lifecycle but does not receive new features. Syntax older than version 3 is not supported.

To use v3 syntax, you have to instantiate the legacy version of the templater:

Development roadmap

Version 4.2 is the current stable contract baseline. The next maintenance and major-version work, its dependencies, and the required decision gates are tracked in the development roadmap. Release history is kept in the changelog.


All versions of templater with dependencies

PHP Build Version
Package Version
Requires php Version ^8.0
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 hokoo/templater contains the following files

Loading the files please wait ...