PHPackages                             proger/htmlki - 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. proger/htmlki

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

proger/htmlki
=============

Seamless templating with the HTML spirit.

472PHP

Since Jan 27Pushed 5y ago1 watchersCompare

[ Source](https://github.com/ProgerXP/HTMLki)[ Packagist](https://packagist.org/packages/proger/htmlki)[ RSS](/packages/proger-htmlki/feed)WikiDiscussions master Synced 4d ago

READMEChangelogDependenciesVersions (1)Used By (0)

HTMLki - seamless templating with the HTML spirit
=================================================

[](#htmlki---seamless-templating-with-the-html-spirit)

**HTMLki** takes a non-mainstream approach. Unlike inventing yet another PHP or Mustache it imbues old good HTML with new features - loops, variables, localization, custom tags and more without breaking its original clean form.

```

    $caption

```

What we see here is:

- A loop: `` is only output if there's at least one item in `$menu`
- An "if": `` is only output if `$icon` is non-falsy
- A bunch of attribute magic: `` (``), `` (``)
- Anti-XSS: `$caption` is a variable, **escaped by default**

It has no dependencies and works out of the box in **PHP 5.6 and above**.

\[ [Full documentation](http://squizzle.me/php/htmlki) \]

Usage
-----

[](#usage)

**Available for Composer** under `proger/htmlki` at [Packagist](https://packagist.org/packages/proger/htmlki).

**Standalone:**

```
// Configure your autoloader to load the HTMLki namespace from class/HTMLki/.

echo HTMLki\HTMLki::template(HTMLki\HTMLki::compile(''));
  //=>
```

Features
--------

[](#features)

Because HTMLki is just HTML on steroids, any text editor with HTML/PHP syntax scheme gets highlighting right most of the time.

HTMLki imbues HTML with:

- XSS protection - output is HTML-escaped **by default**
- [loops and conditions](http://squizzle.me/php/htmlki#loops) - like in the above example: `` and ``
- [attribute magic](http://squizzle.me/php/htmlki#attr) - automatic expansion of `` into ``, `` into `` and more
- [tag magic](http://squizzle.me/php/htmlki#tags)
    - shortcuts (`` into ``)
    - multitags (`` into ``)
    - singletags (`` into ``)
    - and more
- [language lines](http://squizzle.me/php/htmlki#language) - simply any text wrapped in double quotes: `"Hello!"`
- [expressions and variables](http://squizzle.me/php/htmlki#brackets) - like `{ date('d.m.y') }`
- [PHP code](http://squizzle.me/php/htmlki#php) - just as you guess: `` - short PHP tags expanded automatically so you don't have to care about any particular `php.ini` settings
- [function-tags](http://squizzle.me/php/htmlki#funcs) - in form of custom tags like ``
- [input checking](http://squizzle.me/php/htmlki#input) - clearly see what the template accepts: `$>currentPage@1 int
