I'm attempting to use a view helper to create some dynamic links based on if you're logged in or not.
What I want returned, for sake of easy code readability, is:
<ul class="right">
<li><a href="#">Login</a></li>
<li><a href="#">Register</a></li>
</ul>
In the view helper I have this Ruby code:
def loginh
xm = Builder::XmlMarkup.new(:indent=>2, :margin=>4)
xm.ul("class" => "right") {
xm.li('class' => 'text') {
xm.text("test")
}
}
end
In the view, the line that calls login helper is already indented 4 levels. Because of this, the first line gets 'skewed', so in the view I have:
<%= loginh %>
Which results in:
<ul class="right">
<li class="text">
<text>test</text>
</li>
</ul>
You can see it works perfectly, except for the first line. It would appear that the first line is affected by the indent before <%= loginh %> is called.
I can easily remedy this by removing the indentation prior to <%= loginh %> - but in essence I'd be sacrificing code readability for markup readability. Which isn't what I'm looking to do.
Is there any way I could remove the beginning whitespace?