PHPackages                             edevelops/native-tpl-heir - 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. edevelops/native-tpl-heir

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

edevelops/native-tpl-heir
=========================

Tiny plain PHP native template inheritance library

0.0.1(5y ago)38MITPHPPHP &gt;=7.4

Since May 30Pushed 5y ago1 watchersCompare

[ Source](https://github.com/idashevskii/native-tpl-heir)[ Packagist](https://packagist.org/packages/edevelops/native-tpl-heir)[ RSS](/packages/edevelops-native-tpl-heir/feed)WikiDiscussions main Synced today

READMEChangelog (1)Dependencies (1)Versions (2)Used By (0)

Tiny plain PHP native template inheritance library

[![Latest Stable Version](https://camo.githubusercontent.com/0034bcf91df833fa8210228011a4f31cbbf8084eee5cacc56a9d814afd6b5888/68747470733a2f2f706f7365722e707567782e6f72672f65646576656c6f70732f6e61746976652d74706c2d686569722f76)](//packagist.org/packages/edevelops/native-tpl-heir) [![Total Downloads](https://camo.githubusercontent.com/0cf6786b5900b5be3afaaa7665a202829d8d34dfa882b156ad8a7463cbdda950/68747470733a2f2f706f7365722e707567782e6f72672f65646576656c6f70732f6e61746976652d74706c2d686569722f646f776e6c6f616473)](//packagist.org/packages/edevelops/native-tpl-heir) [![Latest Unstable Version](https://camo.githubusercontent.com/fa374520d4dd7fc00bfed231da57bb083e9990b2308a9b42136856e7352a45af/68747470733a2f2f706f7365722e707567782e6f72672f65646576656c6f70732f6e61746976652d74706c2d686569722f762f756e737461626c65)](//packagist.org/packages/edevelops/native-tpl-heir) [![License](https://camo.githubusercontent.com/b98e9bd8ac1bdb3e52055ecfa29e99fc46e77db24443640352959748c58ac1d3/68747470733a2f2f706f7365722e707567782e6f72672f65646576656c6f70732f6e61746976652d74706c2d686569722f6c6963656e7365)](//packagist.org/packages/edevelops/native-tpl-heir)

Inspired by [phpti](https://github.com/arshaw/phpti)

Features
--------

[](#features)

- About 35 lines of code at all
- No needs to know any template language other than PHP
- The entire API is just 3 global functions!
- Overridable blocks are not executed!
- No `ob_*` buffering used

Usage
-----

[](#usage)

Without composer: just copy/include tiny [source](src/NativeTplHeir.php) directrly.

Using composer:

```
$ composer require edevelops/native-tpl-heir

```

Then need to touch `NativeTplHeir` class to trigger auto-loading. For example

```
new NativeTplHeir();
```

**API**

- `slot(string $name, Closure $render = null)` - the output point of the block in the template. `$name` - unique block name. `$render` - optional callback for rendering.
- `block(string $name, Closure $render)` - defining block to output in the `slot` of parent template. `$name` - unique block name. `$render` - callback for rendering.
- `super()` - calling the overridden parent's callback for rendering.

**Inheritance**

Just include parent template **at the end** of file.

Example
-------

[](#example)

**root.php:**

```
?>
