This course will become read-only in the near future. Tell us at community.p2pu.org if that is a problem.

[haml] Jumping In [Dec. 21, 2011, noon]


Lets get started, if you haven't already, download Ruby from http://ruby-lang.org/ .

First, we need to download the 2 libraries, open your Terminal and type gem install haml sass This will install the latest version of the gems.

Now, both of the compilers can be invoked from the command line. Lets write some haml and compile it. First, open a file with a .haml extension and type: 


!!!5
%html{lang: "en"}
  %head
    %title Test
  %body
    #content= "App"

To compile, invoke the command-line compiler by typing haml <file>.haml after the compilation, the results should be shown on screen. If you want the results to be outputted to a file type: haml <file>.haml <output>.html you can also replace the .html with .erb if your file needs to be dynamic.

Lets dissect this, line by line. The first line declares the <!DOCTYPE> the prefixed 5 sets it to HTML5.

The second line open the <html> tag and adds the lang attribute using a Ruby hash.

The third line open the <head> tag.

The fourth line opens the <title> tag and puts 'Test' inside it.

The fifth line opens the <body> tag and the sixth line creates a div with an id of content and some very simple Ruby code.


As you can see, Haml uses indentation to show nested tags

[Incomplete]