2017 © Pedro Peláez
 

library pate

Pate is a PHP Attribute Template Engine inspired by PHPTAL but run much faster. It use native dom to make it fast.

image

softwarezhu/pate

Pate is a PHP Attribute Template Engine inspired by PHPTAL but run much faster. It use native dom to make it fast.

  • Wednesday, March 22, 2017
  • by softwarezhu
  • Repository
  • 1 Watchers
  • 0 Stars
  • 5 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 4 Versions
  • 0 % Grown

The README.md

Pate

Pate is a PHP Attribute Template Engine inspired by PHPTAL but run much faster. It uses syntax like angular and vue, But renders on the server side. It's compatible with PHPTAL., (*1)

Why Use Pate Instead Of PHPTAL?

I use PHPTAL as our template engine in one of my Project. But is was TOO SLOW!!, and TOO COMPLICATED. So I decide to rewrite a similar Template Engine named PATE., (*2)

Here are some advantages: * TREE times faster than PHPTAL. PHPTAL takes several seconds to render a big page(abount 150k), but PATE is more than 3 times faster. * PATE is Extremely Extensible. PATE is designed for extensible, You can create your own Syntax to enhance PATE's feature. * PATE is Extremely Easy. There are only 1/10 codes of PHPTAL, but much more powerful. * PATE's compiled file is VERY READABLE. But PHPTAL's compiled file is complicated and very hard to read. * PHPTAL is too strict with dom and variables, error occurs frequently. Pate is friendly., (*3)

Requirements

To use Pate, you need, (*4)

  • PHP >= 5.4., (*5)

  • With dom extension installed., (*6)

Install

With composer, (*7)

composer require softwarezhu/pate, (*8)

Examples

Attributes

Template file, (*9)

<html>
<head>
</head>
<body>
<img tal:attributes="src data/src; alt data/title"/>
</body>
</html>

Do render(ie. This template is named 'template.html'), (*10)

use Pate\PateTemplate;

$template = new PateTemplate();
$template->loadHtmlFile('template.html');
$content = $template->render(array(
    'data' => array(
        'src' => 'htttp://github.com/logo.jpg',
        'title' => 'Github Logo'
    )
));

echo $content;

The render result will be, (*11)

<html>
    <head>
    </head>
    <body>
        <img src="htttp://github.com/logo.jpg" alt="Github Logo"/>
    </body>
</html>

Template Syntax

Attributes

 <img tal:attributes="src data/src; alt data/title"/>

The img src and alt attributes will be replaced by the data['src'] value and data['title'] value. The multiple attributes use ";" to separate., (*12)

Text

 <span tal:content="data/title">This content will be replaced after rendered. </span>

Loop

<tr tal:repeat="product products" tal:content="product/title">This content will be replaced by product/title after rendered. </tr>

If the count of products is N, there will be N tr lines., (*13)

If

 <div tal:condition="product/isPromote" tal:content="product/discount">If product/isPromote is false, this block will be removed from the dom. </div>

tal:condition likes if in php., (*14)

Replace

html <div tal:replace="123">This entire DIV will be replaced with '123'(not the inner text). </div>, (*15)

The Versions

22/03 2017

dev-master

9999999-dev

Pate is a PHP Attribute Template Engine inspired by PHPTAL but run much faster. It use native dom to make it fast.

  Sources   Download

LGPL-2.1+

The Requires

  • ext-dom *
  • php >=5.3

 

The Development Requires

by piggy

template engine zope pate

21/03 2017

1.1.1

1.1.1.0

Pate is a PHP Attribute Template Engine inspired by PHPTAL but run much faster. It use native dom to make it fast.

  Sources   Download

LGPL-2.1+

The Requires

  • php >=5.3
  • ext-dom *

 

The Development Requires

by piggy

template engine zope pate

21/03 2017

1.1

1.1.0.0

Pate is a PHP Attribute Template Engine inspired by PHPTAL but run much faster. It use native dom to make it fast.

  Sources   Download

LGPL-2.1+

The Requires

  • php >=5.3
  • ext-dom *

 

The Development Requires

by piggy

template engine zope pate

20/03 2017

1.0

1.0.0.0

Pate is a PHP Attribute Template Engine inspired by PHPTAL but run much faster. It use native dom to make it fast.

  Sources   Download

LGPL-2.1+

The Requires

  • php >=5.4
  • ext-dom *

 

The Development Requires

by piggy

template engine zope pate