You don't need a block for this, you just need a local variable.

chris

On Wed, Mar 16, 2011 at 7:28 AM, Szymon Nowak <[email protected]> wrote:

> Hey,
>
> in ERB it was possible to use tap to not repeat some calculations, e.g.:
>
> <% Model.some_complex_query.tap do |result| %>
>   <%= something if result.size > 0 %>
>   <% result.each {} %>
> <% end %>
>
> and so on...
>
> When I try similar thing it in Haml it displays the value of the tapped
> object after executing the block.
>
> - "string".tap do |s|
>   -# nothing here
>
> will display "string", because it simply executes the code and #tap returns
> the original object after executing the block. Is there a way to get similar
> behavior as in ERB?
>
> Cheers,
> Szymon
>
> --
> You received this message because you are subscribed to the Google Groups
> "Haml" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> 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 [email protected].
To unsubscribe from this group, send email to [email protected].
For more options, visit this group at http://groups.google.com/group/haml?hl=en.

Reply via email to