Parsing standalone haml files into html output
You’ve heard of HAML – a nice simple elegant parser for structured text that relies ‘shortcut’ thinking and ‘whitespace’ position.
That’s it. It is built around the idea of the simplest thing that can possibly work, ‘make sense’ but not too cryptic.
Of course everybody seems to use it for layouts and templates, I tried to use haml for some general test notes taking. I think I will stick with textile for that. Here is some ‘general’ test text in haml created as test.haml file.
%strong Hello Bold World
%p This is a paragraph
.story
this is going to be a div with class named story. We can keep typing for a long time
this is the beginning of a second line
this is a third line with a blank line above
%h3 this is h3 heading
%p paragraph one line
%p
paragrap multiline
second line
the next line
%h2 this is h2 headline
.story
this is nested div class textile with nexted textile markup
.txtile
:textile
h2. this is textile h2 heading
this is back to regular story div
%p paragraph saying that p below is a ruby expression
%p= Time.now
Given I have “Haml gem installed” I run a parser haml test.haml test.html and I open htm file which looks like this.
<strong>Hello Bold World</strong> <p>This is a paragraph</p> <div class='story'> this is going to be a div with class named story. We can keep typing for a long time this is the beginning of a second line this is a third line with a blank line above </div> <h3>this is h3 heading</h3> <p>paragraph one line</p> <p> paragrap multiline second line the next line </p> <h2>this is h2 headline</h2> <div class='story'> this is nested div class textile with nexted textile markup <div class='txtile'> <h2>this is textile h2 heading</h2> </div> this is back to regular story div </div> <p>paragraph saying that p below is a ruby expression</p> <p>Sat May 16 19:40:50 -0500 2009</p>
Very simple elengant stuff. Great for layouts and templates and not for general notes writing like I normally do in textile.
But haml is definitly on my list for generating layouts for test cases and UseCases at some point.