Download the PHP package aleksandr.ru/template-object without Composer

On this page you can find all versions of the php package aleksandr.ru/template-object. 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-object

TemplateObject

Another simple template parser. Also available via composer:

Features

Markup example

header.html

page.html

footer.html

Code example

in case of not usage the 'row' block, content of EMPTY will be shown

Extending templates

Since 2.0 there is an abilty to extend templates. For example:

yeild.html

extend.html

The code is the same:

Recursive blocks

Since 2.4 there is an abilty to make your blocks recursive. For example:

recursive.html

The code:

Output:

Function quick reference

static loadTemplate(string $file) : TemplateObject

Load template from file.

__construct(string $data = '', string $base_dir = '')

Constructor.

__destruct()

Free and reset resources.

getBlocks() : array

Returns all blocks found in the template. Only 1st level of blocks are returned, not recursive.

getVariables() : array

Returns all variables found in template. Only variables outside of blocks are returned.

setBlock(string $blockname) : TemplateObject

Set block for usage (add a new block to markup and return handle).

setGlobalVariable(string $var, string $val) : boolean

Set a variable in global scope.

setVariable(string $var, string $val) : boolean

Set the variable in markup. Triggers E_USER_NOTICE if variable was not found.

setVarArray(array $arr)

Set variables from an array like

getOutput() : string

Get parsed template with all data set.

showOutput()

Print parsed template with all data set.

addFilter(string $filter, callable $callback, boolean $overwrite = FALSE) : boolean

Add (or replace) a filer for variables. Triggers E_USER_NOTICE if filter already exists and no $overwrite. Triggers E_USER_NOTICE when given $callback is not callable.

removeFilter(string $filter) : boolean

Remove an existing filter. Triggers E_USER_NOTICE if filter does not exists.

getForcedFilter() : string

Since 2.7. Get current forced filter.

setForcedFilter(string $filter) : boolean

Since 2.7. Set new forced filer. By default, is set to "html". Triggers E_USER_WARNING if filter does not exist.

Forced filter is filter to be applied first if there is no "raw" filter and no same filter is set for variable. Forced filter can contain several elements like html|nl2br, each will be prepended to variable's filters, if is not set.

This mechanism may cause some backwards compatibility issues: before 2.7 {{VAR}} means {{VAR|html}} and {{VAR|js}} means only {{VAR|js}} (no html applied), since 2.7 {{VAR}} means {{VAR|html}} and {{VAR|js}} means {{VAR|html|js}} (html is forcefully prepended). To get back old behaviour of {{VAR|js}} you need to add "raw" filter like {{VAR|raw|js}}.

More documentation

See PhpDoc in code.

Version history


All versions of template-object with dependencies

PHP Build Version
Package Version
Requires php Version >=5.3.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 aleksandr.ru/template-object contains the following files

Loading the files please wait ...