The main benefits are:
- no switching between php and html or echoing of html strings needed when you are inside your php stuff.
- Minimalistic usage attempt and helper functions. You should be able to generate more html markup with less php instructions while keeping full flexibility.
- Auto-indention. Unless you turn it of to save whitespace you will receive beautifully indented and super-readable markup for your web-projects.
The main downfalls are:
- Page generation takes longer, because every html-tag will run through a lot of php functions while being generated.
(I use it along with wordpress and can not make a humanly noticeable difference in page loading speed when changing from a default wp-theme to one that uses the generator.) - It may be difficult to learn how to use this, compared to writing pure html.
This project is inspired by the CakePHP HtmlHelper.
Demo-/Testpage
Documentation(phpDocumentor)
- Download the latest "alldeps" branch
- Extract the archive and upload the plugin into the
/wp-content/plugins/
directory of your wordpress project. - Activate the plugin through the 'Plugins' menu in WordPress
Use composer and require "xiphe/html": "2.0.*"
or download the latest "alldeps" branch,
extract it and put it anywhere in your php project.
Then include [path to]/bootstrap.php
or [path to]/vendor/autoload.php
.
Follow the Installation steps to initiate the global $HTML variable.
<?php
/* Get access to an instance of Xiphe\HTML */
global $HTML
/* Opens a std HTML5 header - leaves you inside the <head> */
$HTML->HTML5()
/* print a <title> */
->title('HTML Example')
/* close the <head> tag */
->close('head')
/* open a <body> tag (s_[tag] will just open a [tag] - no </tag> will be echoed) */
->s_body()
/* open a <div> tag with the class attribute "wrap" */
->s_div('.wrap')
/* open an <article> tag with an id */
->s_article('#article1')
/* print a <h1> with multiple attributes */
->h1('Hello Stranger', array('style' => 'color: red;', 'rel' => 'title'))
/* <3 */
->p('Thank you for checking out Xiphe\HTML - that\'s very kind of you')
/* Another way to pass multiple attributes to a tag */
->img('src=http://upload.wikimedia.org/wikipedia/commons/c/ce/Example_image.png|alt=example')
/* close all Tags that have been opened previously */
->close('all');
Output:
<!DOCTYPE HTML>
<html class="no-js">
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<meta content="IE=edge,chrome=1" http-equiv="X-UA-Compatible" />
<title>HTML Example</title>
</head>
<body>
<div class="wrap">
<article id="article1">
<h1 rel="title" style="color: red;">Hello Stranger</h1>
<p>Thank you for checking out Xiphe\HTML - that's very kind of you</p>
<img alt="example" src="http://upload.wikimedia.org/wikipedia/commons/c/ce/Example_image.png" />
</article><!-- #article1 -->
</div><!-- .wrap -->
</body>
</html><!-- .no-js -->
Want to dig deeper? poke me to write a better documentation. Or check out the Test/Examples Hybrid on html.xiphe.net.
-
Js/Css Minifiying from Fat-Free Framework
Distributed under the GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007
Copyright (c) 2009-2012 F3::Factory/Bong Cosca -
PHP Diff by Chris Boulton (Used for the Demos/Tests. Will not be loaded in productive usage).
BSD License
Copyright (c) 2009 Chris Boulton chris.boulton@interspire.com
All rights reserved. -
Markdown
PHP Markdown & Extra
Copyright (c) 2011, Dragonfly Development Inc
All rights reserved.Based on PHP Markdown & Extra
Copyright (c) 2004-2009 Michel Fortin
http://michelf.com/
All rights reserved.Based on Markdown
Copyright (c) 2003-2006 John Gruber
http://daringfireball.net/
All rights reserved. -
phpDocumentor was used to generate the documentation under /doc
- mergeClasses method added to core\Generator
- minor bugfixes and compatibility to THETOOLS v1.0.7
- Select Module updated
- New Logic for Content::compress()
- Googleanalytics Module allowes $HTML->googleanalytics('UA-0000000-0') for a simple, compressed ga tracker code
- Added basic Sublime Text 2 snippet
- fixed bugs related to Store::get()
- desktop/mobile classes on html tag if THETOOLS are available.
- callbacks for tags
- configuration modes
- bugfixes
- fixed wp textdomain error
- if() and endif() pseudotags
- BasicModule::generate() generates a default tag using the module parameters.
- When Generator::call is called directly, tag options can now be passed as a third argument in addition to prefix them to the Tag
- composer update test.
- composer compatible.
- now uses composer versions off php-diff and markdown.
- COMPLETE REMAKE. Most functionality should still work the same way as in 1.x but most likely not everything.
- Introducing the Xiphe\HTML namespace
- Better modular OOP Structure
- Minimalistic Instances + most logic is now static.
- Tag Instances
- Test Cases
- much more...
- see changelog.txt
- The fist line of a multi-lined <li> has a false indention when cleaned with strong mode.
- radio and checkbox group generation
- Functionality to add own modules and manipulate the TagInfo Class.
- More Test Cases
- Still better documentation
- Array-style attribute maipulation on Tags would be nice. $Tag[id] = 'myID';