Download the PHP package redcatphp/templix without Composer

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

No longer actively maintained. I work now with NodeJS and I recommand you to take a look at ReactJS, Next.JS and EJS

Templix

Templix is a powerfull markup syntax based template engine.
Features

Templix syntax

The Templix syntax is based on diple sign < and >, so if you want to use them for other purpose than opening or closing a markup declaration, you have to use their html entites equivalent which are > and <.
The templix syntax is based on PHP and HTML5/XML, but like HTML5 add the shortcut attribute to XML, Templix add the shortcut value to HTML5:

The markup between comment will not be parsed excepting the PHP.

onCompile binder

You can bind to templix some callback to trigger when the document is almost compiled and all its DOM is accessible.

Options

Dev

Paths

Paths to Plugins

Paths to plugins are based on class namespace and eventually, autoloading. Each class plugin name end with the upper case of first charater of markup and start with prefix which can be a namespace (ending with \\) or simple prefix.

Path relativity

The following rules are valable when you use directly PHP API display or setPath as same as you use markups include, extend, incorpore or attribute applyFile.

no prefix - look in each working directories of template and each parent templates

"./" prefix - look in priority in same directory than the current template

"/" prefix - look in priority in at root of working directories in order they are defined

"//" prefix - look in priority for abosulte path

HTML5 Plugins

XHTML

The main differences between HTML5 and XML/XHTML syntax is that in XML syntax we have to close every elements, it support self closing but there is not implicit self closing unlike in HTML5. In XML there is no support for shortcut attributes, all attributes have to be composed by a key and a value. In XML we have also to convert all HTML named entities in their numeric entities equivalent. The doctype is also different but except these few variations we can switch from one to other very simply.
In Templix if you change html5 doctype declaration "" to "", the output syntax will be automaticaly changed to XHTML without any change to do in your templates !
The parser support the most flexible syntax than is HTML5 with some Templix addons pecificity like shortcut value but, by dint of DOM conversion to PHP object, the output can be changed in XML very easyly. According to W3C specification, the following elements are implicitly self-closed:

Markup Object Methods

Markups object will be called node in following documtentation.

closest

The closest method is used to find through the node's ancestors the first matching element which are closest from the current node.

searchNode

The searchNode method is used to find the index of a node in the children nodes of the node if it's there. The second parameter can be used to start search from an index.

match

The match method is used to determine if a node is corresponding to a selector.

find

The find method is used to find matching selector in all enclosed nodes. The second parameter can be used to specify an index of result.
If you specify an index to "true" the result will not be an array of nodes but a nodes iterator object which you'll can traverse like an array and using a foreach but which can also be used to call sub methods like to a regular node.

children

The children method is used to find matching selector in first sub-level of nodes. Like in find method, the second parameter can be used to specify an index of result.
If you specify an index to "true" the result will not be an array of nodes but a nodes iterator object which you'll can traverse like an array and using a foreach but which can also be used to call sub methods like to a regular node.

merge

The merge method will merge the parameter node passed to method with children nodes of the node.
If an equivalent node allready exists the node will not be added to avoid duplication. If the parameter is scalar value it will be converted to a tree of nodes.
If the element didn't allready exists, it will be added after existing ones.

premerge

The premerge method will merge the parameter node passed to method with children nodes of the node.
If an equivalent node allready exists the node will not be added to avoid duplication. If the parameter is scalar value it will be converted to a tree of nodes.
Contrary to merge if the element didn't allready exists, it will be added before and not after existing ones.

submerge

The submerge method will merge children nodes of the parameter node passed to method with children nodes of the node.
Like in merge, if an equivalent node allready exists the node will not be added to avoid duplication. If the parameter is scalar value it will be converted to a tree of nodes.

isSameNode

The isSameNode method will compare the node to the node parameter based on children nodes, attributes and class name and will return a boolean. It's an equivalence comparison and not a strict comparison based on object memory reference.

getAttributes

The getAttributes method allow you to get the attributes as an associative array.

hasAttribute

The hasAttribute method allow you to know if an attribute is defined.

getElementsByTagName

The getElementsByTagName method is like the regular javascript method, it get the elements by tag name recursively starting with the calling node itself.

write

The write method will clean the inner head, inner foot and children nodes before appending parameter, head and foot will be conserved. If the parameter is scalar value it will be converted to a tree of node.

append

The append method will add the parameter to children nodes after the existing ones. If the parameter is scalar value it will be converted to a tree of node.

prepend

The append method will add the parameter to children nodes before the existing ones. If the parameter is scalar value it will be converted to a tree of node.

each

The each method receive a callback as argument. It will apply on the node or iterate through an iterator node and apply on each node.

replaceWith

The replaceWith method allow you to replace a node with an other in parent's children nodes. If the parameter is scalar value it will be converted to a tree of node.

remove

The remove method will remove the node from parent's children nodes.

applyFile

The applyFile method will read the filename, usually a ".tpl" file, which contain applicators markup to modify the node like the first level of markups do in extend.

before

The before method will add the parameter just before the node in parent's children nodes. If the parameter is scalar value it will be converted to a tree of node.

after

The after method will add the parameter just after the node in parent's children nodes. If the parameter is scalar value it will be converted to a tree of node.

getIndex

The getIndex method return the index of the node in parent's children nodes.

getInnerMarkups

The getInnerMarkups method return the string version of inner children nodes.

getInner

The getInner method return the string version of inner head, then inner children nodes, and finaly inner foot.

__toString

The __toString method return the whole node and all enclosed node as a string. This magic method is returned when you try to cast the node as string.

clear

The clear method erase head, inner head, children nodes, inner foot, foot, previous sibling, next sibling, detach itself from the next and previous flow and set hiddenWrap to hide markup opener and closer output.

clearInner

The clearInner method erase inner head, children nodes and inner foot.

head

The head method unshift a raw content or source code to the head of the node, before opening markup. A second parameter can be used to specify a splice index. If the splice index is true the raw content will be pushed instead of unshifted.

foot

The foot method push a raw content or source code to the foot of the node, after closing markup. A second parameter can be used to specify a splice index. If the splice index is true the raw content will be unshifted instead of pushed.

innerHead

The innerHead method unshift a raw content or source code to the inner head of the node, after opening markup. A second parameter can be used to specify a splice index. If the splice index is true the raw content will be pushed instead of unshifted.

innerFoot

The innerFoot method push a raw content or source code to the inner foot of the node, before closing markup. A second parameter can be used to specify a splice index. If the splice index is true the raw content will be unshifted instead of pushed.

attr

The attr method is a getter or setter for accessing attributes. It will be a getter with one argument and a setter with two arguments.

tmpAttr

The attr method is a getter or setter for accessing temporary attributes.
Because of extend or apply, the DOM can be re-compiled to string and re-parsed. In this processus, all unvisible meta-data you can add to your object, like with the data method, will be wiped. So, there is a convention for passing meta-data in a node with the urlencoded key-value pairs "tmp-attr" attribute. This attribute is a visible attribute working with not "hiddenWrap" nodes (visible opening and closing markup), but they will be removed automaticaly just before the end of global compilation.
It will be a getter with one argument and a setter with two arguments.

removeAttr

The removeAttr method remove an attribute from opening markup of node.

remapAttr

The remapAttr method is used for add a key to a shortcut attribute or shortcut value according to its order in attributes. The first argument specify the key to add and the second argument the index of shortcut, starting with zero. The index is zero by default.

data

The data method is a getter or setter for accessing meta-data unvisible attributes.
Because of extend or apply, the DOM can be re-compiled to string and re-parsed. In this processus, all unvisible meta-data you can add to your object, like with the data method, will be wiped. To work around this behavior use tmpAttr instead of data.
It will be a getter with one argument and a setter with two arguments.

css

The css method is a getter or setter for accessing css properties of style attribute. It will be a getter with one argument and a setter with two arguments.

removeClass

The removeClass method allow you to work on class attribute by removing class in a regular way without to have to work on class string attribute directly.

addClass

The addClass method allow you to work on class attribute by adding class in a regular way without to have to work on class string attribute directly and avoiding duplication.

wrap

The wrap method allow you to enclose a node or a tree of nodes in a node. If you pass it a tree of node it will use the first top encloser node as the wrapper. If the parameter is scalar value it will be converted to a tree of node.

unwrap

The unwrap method allow you to remove a wrapper. You can also use a selector to specify the closest matching wrapper you want to remove from ancestors. By default, it will be the closest encloser (selector "*").

createChild

The createChild method will create a node in children node from scalar content.

recursive

The recursive method allow you to execute a callback on each node recursively and also break the recursion from callback context. The callback will be executed from deepers elements to top.

arecursive

The recursive method allow you to execute a callback on each node recursively and also break the recursion from callback context. Contrary to recursive the callback will be executed from top elements to deepers.

getIterator magic

The getIterator magic method allow you to work with children nodes like if they were array of nodes and iterate over them with a foreach loop.

offsetSet magic

The offsetSet magic method allow you to work with children nodes like if they were an array of nodes and set a child node like an offset. If the parameter is scalar value it will be converted to a tree of node.

This is equivalent to:

offsetGet magic

The offsetGet magic method allow you to work with children nodes like if they were an array of nodes and get a child node like an offset.

This is equivalent to:

offsetExists magic

The offsetGet magic method allow you check if a child node exists.

This is equivalent to:

offsetUnset magic

The offsetGet magic method allow you to remove a child node.

This is equivalent to:

__get magic

The __get magic method allow you to directly get an attribute.

This is equivalent to:

set magic

The __set magic method allow you to directly set an attribute.

This is equivalent to:

__isset magic

The __isset magic method allow you to directly check if node has an attribute.

This is equivalent to:

__unset magic

The __unset magic method allow you to directly remove an attribute.

This is equivalent to:

__invoke magic

The __invoke magic method allow you to directly work with a collection iterator.

This is equivalent to:

Native Plugins

Attribute Plugins

Some attributes trigger special behaviors injections and then becomes unvisible. The way to implements an attribute trigger function to a markup is to implements a method which will be named with load prefix followed by upper case first character of attribute name. The hyphen "-" in attribute name will be replaced by underscore "_" in method name. If you want to capture all attributes which is prefixed by a name followed by hyphen "-", like "data-" for example, you can implements "loadAttr" method ending with underscore "_". Let's take some example:

Universal Attribute Plugins:

vars

The vars attribute is used to wrap inner content with sprintf interpolation function.

cacheSync

The cacheSync attribute is used with a sync path. The content of the markup will be cached and regenered only if its modified time is older than the modified time of the sync path.

To update the cache

For configure the path of sync files:

cacheStatic

The cacheStatic attribute is used as shortcut attribute to cache indefinitely the content of the markup.

Markup Plugins:

after

Markup usage of after method. The after markup have to be used at first level inside or in ".tpl" with apply. It will add its content in document just after its selector targeted node(s).

append

Markup usage of append method. The append markup have to be used at first level inside or in ".tpl" with apply. It will add its content at end inside its selector targeted node(s).

apply

Markup usage of applyFile method. It's the reversed process of : the .tpl file will be able to use selector markups for work on the content of . The .tpl file is like a kind of application patcher function.

The {{this:property}} special syntax, specific to apply, allow you to access attributes of current targeted node tu build your apply in a more flexible and dynamic way. Tpl file:

The {{compile:callback()}} special syntax, specific to apply, allow you to pre-compile some portions of code using attributes of current targeted node tu build a faster and more consistent compiled template. Tpl file:

attr

Markup usage of attr method. The attr markup have to be used at first level inside or in ".tpl" with apply. It will set its selector targeted node(s) attributes to its attributes and can also use some special behaviors starting by add or remove like addClass or removeClass.

attrappend

The attrappend markup have to be used at first level inside or in ".tpl" with apply. It will append its attributes to its selector targeted node(s) attributes.

attrprepend

The attrprepend markup have to be used at first level inside or in ".tpl" with apply. It will prepend its attributes to its selector targeted node(s) attributes.

before

Markup usage of before method. The before markup have to be used at first level inside or in ".tpl" with apply. It will add its content in document just before its selector targeted node(s).

case

Case is a basic php syntax structural element.

code

The code markup allow you to put unparsed code like in