PHPackages                             kmklabs/xbt - 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. kmklabs/xbt

ActiveLibrary

kmklabs/xbt
===========

XBT

0.2.0(8y ago)018.1k↓22.2%1MITPHPPHP &gt;=5.5.9

Since Dec 28Pushed 8y ago95 watchersCompare

[ Source](https://github.com/KMK-ONLINE/xbt)[ Packagist](https://packagist.org/packages/kmklabs/xbt)[ RSS](/packages/kmklabs-xbt/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (3)Versions (5)Used By (0)

XHP Block Template
==================

[](#xhp-block-template)

Intro
-----

[](#intro)

This is a simple library to compile an XHP template expression into an ordinary Hack class. We do this because we need to have a template inheritance and inclusion in XHP.

Features
--------

[](#features)

- Template block/inclusion
- Accessing outer template from within
- Template inheritance, like `` which will use `path/dot/base.xbt.php`
- Accessing parent blocks with ``

Example
-------

[](#example)

Suppose that we have this `xbt` template, named `template.xbt.php`:

```

    This is a header

        This is inside a block

            This is a block inside a block

    This is a simple footer

```

And have a view file named `welcome.xbt.php`:

```

    Welcome Home

```

Load the file, and using this library, we can convert the template into an XHP class

```
$contents    = file_get_contents("template.xbt.php");
$tokenizer   = new Tokenizer($contents);
$tokenStream = $tokenizer->tokenize();
$parser      = new Parser($tokenStream);
$result      = $parser->parse();

```

`$result` should be like something like this:

```
