Re: [haml] Using tap with Haml to create scoped local variables
I know, but in ERB I prefer using #tap to scope local variable - this way it's only available inside the block where it's needed and not in the whole view. Usually the code can be simply refactored into a helper method, but sometimes it was useful. Thanks, Szymon -- You received this message because you are subscribed to the Google Groups Haml group. To post to this group, send email to haml@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.
Re: [haml] Using tap with Haml to create scoped local variables
I haven't seen this behavior with tap and HAML. For me, it works as you expect: it doesn't output the tapped variable. Are you sure you used a '-' rather than a '='? :brad On Thu, Mar 17, 2011 at 5:51 AM, Szymon Nowak szi...@gmail.com wrote: I know, but in ERB I prefer using #tap to scope local variable - this way it's only available inside the block where it's needed and not in the whole view. Usually the code can be simply refactored into a helper method, but sometimes it was useful. Thanks, Szymon -- You received this message because you are subscribed to the Google Groups Haml group. To post to this group, send email to haml@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. -- 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 haml@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.
[haml] Using tap with Haml to create scoped local variables
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 haml@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.
Re: [haml] Using tap with Haml to create scoped local variables
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 szi...@gmail.com 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 haml@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. -- You received this message because you are subscribed to the Google Groups Haml group. To post to this group, send email to haml@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.