github
Advanced Search
  • Home
  • Pricing and Signup
  • Explore GitHub
  • Blog
  • Login

wilkerlucio / limber-haml

  • Admin
  • Watch Unwatch
  • Fork
  • Your Fork
  • Pull Request
  • Download Source
    • 3
    • 0
  • Source
  • Commits
  • Network (0)
  • Issues (1)
  • Downloads (0)
  • Wiki (1)
  • Graphs
  • Branch: master

click here to add a description

click here to add a homepage

  • Branches (1)
    • master ✓
  • Tags (0)
Sending Request…
Enable Donations

Pledgie Donations

Once activated, we'll place the following badge in your repository's detail box:
Pledgie_example
This service is courtesy of Pledgie.

PHP Implementation of Haml — Read more

  cancel

  cancel
  • Private
  • Read-Only
  • HTTP Read-Only

This URL has Read+Write access

fixed README 
wilkerlucio (author)
Thu May 21 07:44:05 -0700 2009
commit  c7c3d03fb54f99138340265698c4339b1c7d3eb7
tree    202adcd30518a048e09d915733d0079ff67ee90d
parent  dbc56411ee1c73b7628434c40af2a6105aa70d7a
limber-haml /
name age
history
message
file README.rdoc Loading commit data...
directory lib/
directory spec/
README.rdoc

Limber Haml

Haml is a template engine for the common type HTML This is one PHP implementation using the same specification of original next3/haml

This document is a modified version of the original one created at Ruby Haml project(link above) with previous authorization of the author

Using

Just download the package (using git or manual download here), extract at a folder of your preference and require the file *haml.php* at folder lib.

Example:

  <?php

  require "haml/lib/haml.php";

  $haml = new Haml();
  $haml_code = file_get_contents("my_template.haml");
  $html_code = $haml->parse($haml_code);

  echo $html_code;

Formatting

Haml

The most basic element of Haml is a shorthand for creating HTML tags:

  %tagname{attr1='value1' attr2='value2'} Contents

No end-tag is needed; Haml handles that automatically. Adding class and id attributes is even easier. Haml uses the same syntax as the CSS that styles the document:

  %tagname#id.class

In fact, when you’re using the <div> tag, it becomes even easier. Because <div> is such a common element, a tag without a name defaults to a div. So

  #foo Hello!

becomes

  <div id='foo'>Hello!</div>

Haml uses indentation to bring the individual elements to represent the HTML structure. A tag’s children are indented beneath than the parent tag. Again, a closing tag is automatically added. For example:

  %ul
    %li Salt
    %li Pepper

becomes:

  <ul>
    <li>Salt</li>
    <li>Pepper</li>
  </ul>

You can also put plain text as a child of an element:

  %p
    Hello,
    World!

It’s also possible to embed PHP code into Haml documents. An equals sign, =, will output the result of the code. A hyphen, -, will run the code but not output the result. You can even use control statements like if and while:

  %p
    Date/Time:
    - $now = date("d/m/Y H:i:s")
    %strong= $now
    - if strtotime(now) > strtotime("December 31, 2006")
      = "Happy new " . "year!"

Haml provides far more tools than those presented here. Check out the reference documentation in the project wiki.

Indentation

Actually Limber Haml supports only identation with one tab. In newer versions we will implement support for any consistent identation that user needs (with n number of tabs/spaces)

Blog | Support | Training | Contact | API | Status | Twitter | Help | Security
© 2010 GitHub Inc. All rights reserved. | Terms of Service | Privacy Policy
Powered by the Dedicated Servers and
Cloud Computing of Rackspace Hosting®
Dedicated Server