iakio/htmlhelper

Simple secure HtmlHelper

0.1.0 2014-05-09 14:11 UTC

This package is not auto-updated.

Last update: 2024-12-21 16:15:30 UTC


README

Build Status

Simple secure HtmlHelper.

Features:

  • Auto escaping.
  • Fluent interface.

Usage:

<?php
require 'vendor/autoload.php';

use iakio\htmlhelper\HtmlHelper;

$html = new HtmlHelper;

echo $html->h1('Hello, World'), "\n";       // instance method
// <h1>Hello, World</h1>

echo HtmlHelper::h1('Hello, World'), "\n";  // or static method
// <h1>Hello, World</h1>

echo HtmlHelper::a('set attributes', ['href' => 'http://github.com']), "\n";
// <a href="http://github.com">set attributes</a>

echo HtmlHelper::a()
    ->append('fluent')
    ->append(' interface')
    ->attr('href', 'http://github.com'), "\n";
// <a href="http://github.com">fluent interface</a>

echo HtmlHelper::span(['Auto <escape>', HtmlHelper::i('& nested tag')]), "\n";
// <span>Auto &lt;escape&gt;<i>&amp; nested tag</i></span>