Summary | Allows one to write HTML with the Haml markup language |
---|---|
Short name | haml |
Content type | text |
Extension mapping | {"haml"=>"html"} |
Provided by bundle | built-in |
API doc | Webgen::ContentProcessor::Haml |
Description
This processor converts the content, which is assumed to be in the Haml markup language, to valid XHTML by using the Haml library. For detailed information about Haml have a look at the Haml Homepage!
This extension is only available if the haml library is installed. The preferred way to do this is via Rubygems:
$ gem install haml
Usage
Writing page files using the Haml markup is probably not so a good idea – there are other markup languages that lend themselves better to writing content. However, Haml would be a good choice for writing template files (instead of, for example, writing plain HTML interspersed with ERB tags).
Since Haml is a templating language like ERB, you can use the special context
object
(which is an instance of Webgen::Context) in your Haml markup. This object provides the rendering
context and many useful methods.
Have a look at the Haml tutorial for an introduction to the basic syntax of Haml and/or below for a short example.
Example
Here is a short sample of a text in Haml markup:
#content
.row
.span4.content
%h2 Welcome!
%p= context.node['title']
.span8.sidebar
= context.render_block(:name => 'some_block', :notfound => 'ignore')
%h1#myid This a h1 header
%p
You can just write
%b your
paragraphs here and
%a{:href => 'http://someurl.com'} link
them below. This is a
%strong nice
format!
%blockquote.information
Citations are easy too.
Really. And you can assign them attributes.
%ul
%li Lists
%li aren't
%li difficult
%li either.
When processed by this content processor, the output would look like this:
<div id='content'>
<div class='row'>
<div class='span4 content'>
<h2>Welcome!</h2>
<p>content_processor.haml</p>
</div>
<div class='span8 sidebar'></div>
</div>
</div>
<h1 id='myid'>This a h1 header</h1>
<p>
You can just write
<b>your</b>
paragraphs here and
<a href='http://someurl.com'>link</a>
them below. This is a
<strong>nice</strong>
format!
</p>
<blockquote class='information'>
Citations are easy too.
Really. And you can assign them attributes.
</blockquote>
<ul>
<li>Lists</li>
<li>aren't</li>
<li>difficult</li>
<li>either.</li>
</ul>