Tiger
Fierce HTML Nodes.
Install
bower install tigerWhat is this?
I am not fond of embedding HTML in files that should be only PHP, like when writing Wordpress utilities, so I came up with Tiger.
Include Tiger and let the kitten echo the HTML for you. Nest elements via -> or use callbacks to create more complex hierarchies.
Use the HTML tags you already know and pass the attributes as arguments. # and ., shorthand for ids and classes are supported too.
div('#id', '.class1 class2', 'att=value', 'data');Usage
Narrow jumbotron example from Bootstrap. See original here.
<?php
require_once('tiger.php');
doctype();
html('lang=en', function() {
head(function() {
meta('charset=utf-8');
meta('http-equiv=X-UA-Compatible content=IE=edge');
meta('name=viewport content=width=device-width, initial-scale=1');
title('Bootstrap Template');
// Bootstrap
lnk('href=https://maxcdn.bootstrapcdn.com/bootstrap/3.3.0/css/bootstrap.min.css rel=stylesheet');
// HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries
echo '<!--[if lt IE 9]>';
script('src=https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js');
script('src=https://oss.maxcdn.com/respond/1.4.2/respond.min.js');
echo '<![endif]-->';
});
body(function() {
div('.container', function() {
div('.header', function() {
ul('.nav nav-pills pull-right', 'role=tablist', function() {
li('.active', 'role=presentation')->a('href=#', 'Home');
li('role=presentation')->a('href=#', 'About');
li('role=presentation')->a('href=#', 'Contact');
});
h3('.text-muted', 'Project name');
});
div('.jumbotron', function() {
h1('Jumbotron heading');
p('.lead', 'Cras justo odio, dapibus ac facilisis in, egestas eget quam.
Fusce dapibus, tellus ac cursus commodo, tortor mauris
condimentum nibh, ut fermentum massa justo sit amet risus.');
p()->a('.btn btn-lg btn-success', 'href=# role=button', 'Sign up today');
});
div('.row marketing')->div('.col-lg-6')->repeat(3, function() {
h4('Subheading');
p('Donec id elit non mi porta gravida at eget metus.');
});
div('.footer')->p('© Company 2014');
});
script('href=https://maxcdn.bootstrapcdn.com/bootstrap/3.3.0/js/bootstrap.min.js');
});
});Other Links
If you want some more pro, check out the amazing Facebook's XHP.
Help
Do you want to help? Open an issue here. Comments, feedback and / or pull requests are welcome.
License
MIT © Jorge Bucaran