2017 © Pedro Peláez
 

library template

Native PHP template engine

image

ark/template

Native PHP template engine

  • Tuesday, April 26, 2016
  • by ddliu
  • Repository
  • 2 Watchers
  • 10 Stars
  • 180 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 4 Versions
  • 16 % Grown

The README.md

PHP Template Build Status

Native PHP template engine, (*1)

Installation

composer require ark/template

Usage

use Ark\Template\Engine;

$template = new Engine('/path/to/templates/root');

$template->render('index.php', [
    'username' => 'hello'
]);

layout.php:, (*2)

<!DOCTYPE html>
<html>
<head>
    <title><?php $this->block('title');?></title>
</head>
<body>
    <?php $this->block('header');?>
    <?php $this->begin('content');?><?php $this->end();?>
    <?php $this->block('footer');?>
</body>
</html>

index.php:, (*3)

extend('layout.php');?>
begin('title');?>Page Titleend();?>
begin('content');?>
Page Content
end();?>

begin('footer');?>
Custom footer
end();?>

Markups

Declare layout:, (*4)

<?php $this->extend('layout.php');?>

Declare a block:, (*5)


block('blockname');?>


begin('blockname');?>
Block content
end();?>

Include another template:, (*6)

<?php $this->render('another.php');?>

Template Functions

Escaping:, (*7)

<?=$this->escape($username)?>
<!-- or for short -->
<?=$this->e($username)?>

Filter:, (*8)

<?=$this->filter($username, 'strtolower|trim')?>
<?=$this->e($username, 'strtolower|trim');?>

The Versions

26/04 2016

dev-master

9999999-dev

Native PHP template engine

  Sources   Download

MIT

by dong

26/04 2016

v0.1.2

0.1.2.0

Native PHP template engine

  Sources   Download

MIT

by dong

18/11 2015

v0.1.1

0.1.1.0

Native PHP template engine

  Sources   Download

MIT

by dong

22/03 2015

v0.1.0

0.1.0.0

Native PHP template engine

  Sources   Download

MIT

by dong