pHAML

From Seo Wiki - Search Engine Optimization and Programming Languages
Jump to navigationJump to search

pHAML
Developer(s) David Moring
Stable release 0.9 (preview release) / August 4, 2007
Operating system Cross-platform
Type Template Engine
License BSD License
Website phaml.sourceforge.net

pHAML (PHP XHTML Abstraction Markup Language) is a PHP-centric variant of Haml. Haml is a markup language that is used to describe the XHTML of any web document without the use of traditional inline coding.

pHAML adds additional PHP capabilities to Haml, beyond those provided by phpHaml, including template inclusion, variable inclusion, debugging capabilities. pHAML is live software in production in several sites.

pHAML and Haml Similarities

There is no greater fan of the principles behind HAML than pHAML, markup should be beautiful, DRY (don't repeat yourself), well-indented, and the XHTML structure should be clear.

  • The tag creating syntax was kept the same.
  • Spaces are VERY important—tabs and spaces are not equal and may produce “interesting” results (hence the addition of the debugging capability).

pHAML and Haml Differences

This solution was created to enhance Smarty, and also can be integrated into the Zend Framework. There have been other tweaks to assist in the creation of code. Also, PHP and Ruby share a bit, but are a bit different as well.

  • Attributes are literal: there is no Ruby array notation for attribute arrays.
  • Spaces are not tied to a multiple of two, but you should make your code spacing consistent in practice.
  • There are comments (not just the HTML kind).
  • There is no Ruby code integration.
  • There is PHP integration.
  • There are debugging commands, a simple template system, heredoc syntax, html character output, and html4 doctype tags.
  • Smarty integration.
  • Zend Framework integration.
  • All in a single PHP class.

Examples

Example of Code

The pHAML Code

!!!
%html
  %head
    %title Hello World
  %body
    %b Hello World
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
  <head>
    <title>
    Hello World
    </title>
  </head>
  <body>
    <b>
    Hello World
    </b>
  </body>
</html>

The HTML output listing with line numbers is a function in the Zend Framework View that is under testing and will be release with the 1.0 version.

Example with Embedded Debugger On

By simply starting a line with a '?', the class will produce HTML comments that are useful in debugging.

?
!!!
%html
  %head
    %title Hello World
  %body
    %b Hello World
<!-- Debug on -->
<!-- 3:4{!!!}: !!! -->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<!-- 4:4: %html -->
<html>
  <!-- 5:6: %head -->
  <head>
    <!-- 6:8: %title Hello World -->
    <title>
    Hello World
  <!-- 7:6: %body -->
    </title>
  </head>
  <body>
    <!-- 8:8: %b Hello World -->
    <b>
    Hello World
    </b>
  </body>
</html>

Current status

Technical preview is available at Source Forge, Source Forge Site.

External links

If you like SEOmastering Site, you can support it by - BTC: bc1qppjcl3c2cyjazy6lepmrv3fh6ke9mxs7zpfky0 , TRC20 and more...