PHPackages                             kuofp/yatp - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Templating &amp; Views](/categories/templating)
4. /
5. kuofp/yatp

ActiveLibrary[Templating &amp; Views](/categories/templating)

kuofp/yatp
==========

A logic-less PHP template engine

v1.3.2(5y ago)12521MITPHPPHP &gt;=5.4

Since Jan 23Pushed 5y ago1 watchersCompare

[ Source](https://github.com/kuofp/Yatp)[ Packagist](https://packagist.org/packages/kuofp/yatp)[ RSS](/packages/kuofp-yatp/feed)WikiDiscussions master Synced today

READMEChangelog (6)DependenciesVersions (7)Used By (0)

Yatp
----

[](#yatp)

> Yet another [TemplatePower](http://templatepower.codocad.com/)
>
> A logic-less PHP template engine
>
> [中文說明](https://github.com/kuofp/Yatp/blob/master/README.zh-tw.md)

Format
------

[](#format)

Blocks

```
#valid

	...

#valid (with zero or many spaces)

	...

#invalid (must use pair blocks)

```

Marks

```
{mark_name}
```

- **A valid block\_name/mark\_name:** \[A-Za-z0-9\_-\]+
- **A mark\_name should contain at least one alphabet** (update since V1.1)

Get Started
-----------

[](#get-started)

### Install

[](#install)

- Via composer

```
$ composer require kuofp/yatp

```

- Download directly

```
// Require it with the correct path
require_once 'yatp.php';
```

Methods
-------

[](#methods)

### \_\_construct(string $html\_or\_filepath)

[](#__constructstring-html_or_filepath)

```
// Initialize
$tpl = new Yatp('{str}');

// You can use a file (if exists).
$tpl = new Yatp('view.tpl');
```

### render(\[ bool $print = true \])

[](#render-bool-print--true-)

```
// Print to screen by default
$tpl = new Yatp('Hello World!');
$tpl->render();

// Output:
// Hello World!

// Get result without a print
$html = $tpl->render(false);
echo $html;

// Output:
// Hello World!

// PHP code is allowed
$tpl = new Yatp('');
$tpl->render();

// Output:
// Hello World!
```

### block(string $target)

[](#blockstring-target)

```
// Support dot operation
$tpl = new Yatp('

		a.c

		b.c

');
$tpl->block('a.c')->render();

// Output:
// a.c

// Search the most likely one
$tpl = new Yatp('
	a
		b
			c
				d

');
// Equivalent
// $tpl->block('a.b.c.d')->render();
// $tpl->block('c.d')->render();
$tpl->block('a.d')->render();

// Output:
// d

// First is adopted when block is redefined
$tpl = new Yatp('
	1
	2
	3
');
$tpl->block('a')->render();

// Output:
// 1
```

### assign(array $params)

[](#assignarray-params)

```
// Assign to a mark
$tpl = new Yatp('{str}');
$tpl->assign([
	'str' => 'Hello World!'
])->render();

// Output:
// Hello World!

// Assign several times
$tpl = new Yatp('{str}');

// Equivalent
// $tpl->assign([
//    'str' => 'Hi!'
// ])->assign([
//    'str' => 'Hi!'
// ])->render();

$tpl->assign([
	'str' => ['Hi!', 'Hi!']
])->render();

// Output:
// Hi!Hi!

// Assign a variable to block in the same way
$tpl = new Yatp('');
$tpl->assign([
	'str' => 'Hello World!'
])->render();

// Output:
// Hello World!

// You can assign with another block
$tpl = new Yatp('{mark}');
$msg = new Yatp('Hello World!');
$tpl->assign([
	'mark' => $msg->block('block')
])->render();

// Output:
// Hello World!

// Support dot operation, too
$tpl = new Yatp('

		a.c

		b.c

');
$tpl->assign([
	'a.c' => 'replaced'
])->render();

// Output:
// replaced b.c
```

### nest(array $params)

[](#nestarray-params)

```
$tpl = new Yatp('

		{title}

');

$data = [
	['title' => 'Lesson1'],
	['title' => 'Lesson2'],
];

// Equivalent
// $tpl->assign([
//     'li' => [
//         $tpl->block('li')->assign($data[0]),
//         $tpl->block('li')->assign($data[1]),
//     ]
// ])->render();

$tpl->assign([
	'li' => $tpl->block('li')->nest($data)
])->render();

// Output:
//
//     Lesson1: Hello World!
//     Lesson2: Functions
//
```

### debug( void )

[](#debug-void-)

```
$tpl = new Yatp();

$tpl->block('a_missing_block')->assign([
	'a_missing_mark' => '',
	'#wrong style' => ''
])->debug();

// Output:
// Array
// (
//     [0] => Debug info:
//     [1] => block "a_missing_block" is not found
//     [2] => block or mark "a_missing_mark" is not found
//     [3] => block or mark "#wrong style" is invalid
// )
```

Example
-------

[](#example)

view.html

```
{title}

	{title}: {text}

```

php code

```
$tpl = new Yatp('view.html');

$data = [
	[
		'title' => 'Lesson1',
		'text'  => 'Hello World!'
	],
	[
		'title' => 'Lesson2',
		'text'  => 'Functions'
	],
];

$tpl->assign([
	'title' => 'Syllabus',
	'li'    => $tpl->block('li')->nest($data)
])->render();
```

Output:

```
Syllabus

	Lesson1: Hello World!
	Lesson2: Functions

```

###  Health Score

30

—

LowBetter than 62% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity16

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity62

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~274 days

Recently: every ~297 days

Total

6

Last Release

2070d ago

PHP version history (2 changes)v1.0PHP &gt;=5.3

v1.2PHP &gt;=5.4

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/4777494?v=4)[kuofp](/maintainers/kuofp)[@kuofp](https://github.com/kuofp)

---

Top Contributors

[![kuofp](https://avatars.githubusercontent.com/u/4777494?v=4)](https://github.com/kuofp "kuofp (51 commits)")

---

Tags

templating

### Embed Badge

![Health badge](/badges/kuofp-yatp/health.svg)

```
[![Health](https://phpackages.com/badges/kuofp-yatp/health.svg)](https://phpackages.com/packages/kuofp-yatp)
```

###  Alternatives

[twig/twig

Twig, the flexible, fast, and secure template language for PHP

8.4k457.8M6.8k](/packages/twig-twig)[mustache/mustache

A Mustache implementation in PHP.

3.3k46.6M313](/packages/mustache-mustache)[smarty/smarty

Smarty - the compiling PHP template engine

2.4k40.9M448](/packages/smarty-smarty)[timber/timber

Create WordPress themes with beautiful OOP code and the Twig Template Engine

5.7k3.6M127](/packages/timber-timber)[league/plates

Plates, the native PHP template system that's fast, easy to use and easy to extend.

1.5k6.1M262](/packages/league-plates)[eftec/bladeone

The standalone version Blade Template Engine from Laravel in a single php file

8259.3M103](/packages/eftec-bladeone)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
