Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/progerxp/htmlki
Seamless templating with HTML spirit. PHP 5.6+
https://github.com/progerxp/htmlki
html php template-engine
Last synced: about 2 months ago
JSON representation
Seamless templating with HTML spirit. PHP 5.6+
- Host: GitHub
- URL: https://github.com/progerxp/htmlki
- Owner: ProgerXP
- Created: 2013-02-26T09:38:52.000Z (almost 12 years ago)
- Default Branch: master
- Last Pushed: 2021-01-27T17:42:23.000Z (almost 4 years ago)
- Last Synced: 2024-04-01T04:02:59.743Z (9 months ago)
- Topics: html, php, template-engine
- Language: PHP
- Homepage: http://squizzle.me/php/htmlki
- Size: 132 KB
- Stars: 4
- Watchers: 3
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# 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
- ` (`
- `), `` (``)
* 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
**Available for Composer** under `proger/htmlki` at [Packagist](https://packagist.org/packages/proger/htmlki).
**Standalone:**
```PHP
// Configure your autoloader to load the HTMLki namespace from class/HTMLki/.echo HTMLki\HTMLki::template(HTMLki\HTMLki::compile(''));
//=>
```## 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: `='string'?>` - 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 <= $lastPage`
* most constructs can be escaped, such as `""Not a language."`, `{{ not_an_expr }` and `$$notAVar`
* this list is not complete - refer to the [documentation](http://squizzle.me/php/htmlki#syntax) for all enhancementsThe above doesn't require any additional integration code. However, you can tailor HTMLki into a markup ideal for your particular application by adding handlers for specific tags, attributes, etc.
For example, HTMLki can automatically expand `src`, `href` and `action` attributes into full URLs, or have tags like `` that output the list of errors linked to some input field (textarea, selectbox, etc.).
```
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: `