Skip to content
Set of php classes for HTML generation
PHP
Find file
Pull request Compare This branch is 25 commits behind olamedia:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
nbproject
src
tests
.gitignore
LICENSE
README
README.md

README.md

yuki-html

Efficient way to create and modify HTML tags.

Why you should use it

Sometimes you need to return html tag from class, and be able to modify it later: class myImage{ public static function getHtml(){ return ''; } } $img = myImage::getHtml(); // I wanna add alt and style attributes before output, but how I can? echo $img;

So, How?

class myImage{
    public static function getHtml(){
        return yHtmlTag::create('img', array('src' => 'myimage.png'));
    }
}
$img = myImage::getHtml();

Now you can do what you want: $img['alt'] = 'My Image!'; $img['style'] = "border: none;"; echo $img; // My Image! You even able to get attributes echo $img['src']; // myimage.png To remove attributes unset($img['style']); echo $img; // My Image! To wrap $a = yHtmlTag::create('a', array('href'=>'/')); $a->appendChild($img); echo $a; // My Image! To set text, it will be escaped! $a->setText('click here >>'); echo $a; // click here >>

License

MIT

Usage

$head = yHtmlTag::create('head');
$head->appendChild(
        yHtmlTag::create('title')->setText('Page Title')
    );
$head->appendChild(
        yHtmlTag::create('meta', array(
            'name'=>'description', 
            'contents' => 'Page Description'
        )
    );
$head['lang'] = 'en';
echo $head; // Will output generated html code.
Something went wrong with that request. Please try again.