You could do this:

# dashes are actually spaces, for clarity in email
template = <<-EOF.gsub(/^\s{4}/, '')
----%html
------%head
--------%title
------%body
EOF

I tweeted about this last August. =P
http://twitter.com/listrophy/status/3382558239

:brad

On Thu, Jan 28, 2010 at 1:35 PM, Nathan Weizenbaum <nex...@gmail.com> wrote:

> The problem is that, as the error message says, your indentation is
> inconsistent. Once you strip your template, it looks like this:
> https://gist.github.com/c50eed9d9965aae844bc . The first indentation Haml
> sees is for "%head", which is indented 8 spaces. It then expects 8 spaces to
> be the amount you'll indent by in the future, but "%title" is only indented
> by 2 spaces beyond "%head". Thus, it raises an error.
>
>
> On Thu, Jan 28, 2010 at 7:49 AM, P.A. <shama...@hotmail.com> wrote:
>
>> Hi.
>>
>> I have next code.
>>
>> # begin
>> require 'haml'
>>
>> template = %{
>> ------%html
>> --------%head
>> --------%body
>> }.strip
>>
>> Haml::Engine.new(template).render
>> # end
>>
>> It works fine and render the template.
>>
>> But if I add the %title tag inside the %head...
>>
>> # begin
>> require 'haml'
>>
>> template = %{
>> ------%html
>> --------%head
>> ----------%title
>> --------%body
>> }.strip
>>
>> Haml::Engine.new(template).render
>> # end
>>
>> ...I get the error: "Inconsistent indentation: 10 spaces were used for
>> indentation, but the rest of the document was indented using 8
>> spaces."
>>
>> What is the problem of this error? How can I resolve it?
>>
>> Thanks.
>>
>> Debian GNU/Linux 5.0.3;
>> Ruby 1.9.2;
>> Haml 2.2.17.
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Haml" group.
>> To post to this group, send email to h...@googlegroups.com.
>> To unsubscribe from this group, send email to
>> haml+unsubscr...@googlegroups.com <haml%2bunsubscr...@googlegroups.com>.
>> For more options, visit this group at
>> http://groups.google.com/group/haml?hl=en.
>>
>>
>  --
> You received this message because you are subscribed to the Google Groups
> "Haml" group.
> To post to this group, send email to h...@googlegroups.com.
> To unsubscribe from this group, send email to
> haml+unsubscr...@googlegroups.com <haml%2bunsubscr...@googlegroups.com>.
> For more options, visit this group at
> http://groups.google.com/group/haml?hl=en.
>



-- 
Bradley Grzesiak
co-founder, bendyworks llc
http://bendyworks.com/

-- 
You received this message because you are subscribed to the Google Groups 
"Haml" group.
To post to this group, send email to h...@googlegroups.com.
To unsubscribe from this group, send email to haml+unsubscr...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/haml?hl=en.

Reply via email to