<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Schadenfreude &#187; haml</title>
	<atom:link href="http://www.ralree.com/tag/haml/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.ralree.com</link>
	<description>Malicious enjoyment derived from observing someone else's misfortune</description>
	<lastBuildDate>Sun, 28 Feb 2010 04:18:37 +0000</lastBuildDate>
	
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Cheating on ERB with HAML</title>
		<link>http://www.ralree.com/2007/02/08/cheating-on-erb-with-haml/</link>
		<comments>http://www.ralree.com/2007/02/08/cheating-on-erb-with-haml/#comments</comments>
		<pubDate>Thu, 08 Feb 2007 01:30:50 +0000</pubDate>
		<dc:creator>Erik</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[haml]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://www.ralree.info/2007/10/13/cheating-on-erb-with-haml</guid>
		<description><![CDATA[Flash!! Zoom!!

!!!
%html
  %head
    %link{ :rel =&#62; "shortcut icon", :href =&#62; "/favicon.ico", :type =&#62; "image/x-icon"}/
    %title= "Wallpaper Love Factory :: "+controller.controller_name.capitalize
    = stylesheet_link_tag 'wallpaper'
  %body
    .header#header
      = render :partial =&#62; 'layouts/header'
      .menu#menu= [...]]]></description>
			<content:encoded><![CDATA[<h3>Flash!! Zoom!!</h3>
<pre><code>
!!!
%html
  %head
    %link{ :rel =&gt; "shortcut icon", :href =&gt; "/favicon.ico", :type =&gt; "image/x-icon"}/
    %title= "Wallpaper Love Factory :: "+controller.controller_name.capitalize
    = stylesheet_link_tag 'wallpaper'
  %body
    .header#header
      = render :partial =&gt; 'layouts/header'
      .menu#menu= render :partial =&gt; 'layouts/menu'
    .content#content= yield
</code></pre>
<p>It&#8217;s so easy!  Anyone can do it.  HAML is sweeping the rails world like a wildfire of chicken, and everyone wants the biggest piece.  I decided to try it last night on my new wallpaper site, and found that it&#8217;s extremely awesome to work with.  As you can see above, I used it for my <strong>application.haml</strong> layout.  Here&#8217;s a breakdown of wtf is going on up there:</p>
<ul>
<li><strong>!!!</strong>:  That pesky DOCTYPE crap line that everyone hates and googles all the time.</li>
<li><strong>%tag</strong>:   You use % to denote a new tag, and close it with indentation, like Python.</li>
<li><strong>%link{:rel => &#8220;shortcut icon&#8221;}</strong>:   All the tag attributes are just a ruby hash!</li>
<li><strong>= stylesheet_link_tag &#8216;wallpaper&#8217;</strong>:  Use the <strong>=</strong> to evaluate Ruby and display it.</li>
<li><strong>.header</strong>:   Makes a div with a class of &#8216;header&#8217;.</li>
<li><strong>.header#homie</strong>:   Makes a div with a class of &#8216;header&#8217; and an id of &#8216;homie&#8217;.</li>
<li><strong>.menu#menu= render :partial => &#8216;layouts/menu&#8217;</strong>:  Should be obvious by now.  Renders a partial within a div with class &#8216;menu&#8217; and id &#8216;menu&#8217;.</li>
</ul>
<p>I found that it&#8217;s ridiculously easy to write views now.  But what about loops?</p>
<pre><code>
- @wallpapers.each do |w|
  .image[w]
    = w.name

# Makes:

&lt;div class='wallpaper image' id='wallpaper_4'&gt;
  Manatee
&lt;/div&gt;
</code></pre>
<p>Holy dog crap!  You don&#8217;t even have to use <strong>end</strong> anymore!  It&#8217;s all Python style!<br />
Now, if you want to have even more fun, you can make self closing tags like <strong>img</strong>!:</p>
<pre><code>
%img{:src =&gt; 'your_face.jpg'}/

# Produces

&lt;img src='your_face.jpg'/&gt;
</code></pre>
<p>This is probably a bad example because the HAML is actually longer than the result, but <strong><em>who cares</strong></em>!!!</p>
<p>For more tricks and stuff, check out the <a href="http://haml.hamptoncatlin.com/reference">HAML reference</a> and <a href="http://haml.hamptoncatlin.com/tutorial">tutorial</a>.  </p>
]]></content:encoded>
			<wfw:commentRss>http://www.ralree.com/2007/02/08/cheating-on-erb-with-haml/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
	</channel>
</rss>

<!-- Dynamic Page Served (once) in 0.309 seconds -->
