Usually helpers or partials are used for avoiding code duplication. On Mon, Aug 23, 2010 at 5:33 AM, Ashish Bhatia <[email protected]>wrote:
> OK thanks for that piece of info. > My basic problem is that I wish to generate two identical forms (with > differences in names,id of the fields) > And the haml code is 100 lines. So, rather than duplicating the code > is there some way to parameterize with/without using ruby functions. > Can you please suggest an alternate? > > Regards, > Ashish > > On Aug 23, 2:20 am, Nathan Weizenbaum <[email protected]> wrote: > > This is a consequence of the way Ruby and Haml work. The function doesn't > > have access to some of the local variables (namely _hamlout) that Haml > needs > > to run. Thus putting Haml code in the function won't work. > > > > On Fri, Aug 20, 2010 at 11:21 AM, Ashish Bhatia > > <[email protected]>wrote: > > > > > This code snippethttp://pastebin.com/nuH20vBQ > > > produces following errorhttp://pastebin.com/9WThiUHR > > > > > Whilehttp://pastebin.com/rkky0Mj8does the same thing without > > > producing the error > > > So, essentially the problem is that any html output (using =) inside a > > > function call is creating a problem (not just merb helpers which were > > > mentioned in the original post) > > > > > On Aug 19, 11:38 pm, Nathan Weizenbaum <[email protected]> wrote: > > > > Can you give an example of the code that's causing this problem? > > > > > > On Thu, Aug 19, 2010 at 11:15 AM, Ashish Bhatia > > > > <[email protected]>wrote: > > > > > > > Hi, > > > > > > > I have written a ruby function inside haml and calling it from > there, > > > > > but if the function outputs merb form helpers(like select or > > > > > text_field) > > > > > the code gives an error "undefined local variable or method > `_hamlout' > > > > > " > > > > > can someone please help > > > > > > > Note: I have to perform a ~100 LOC task twice therefore, instead of > > > > > copying the code , I am doing it using ruby functions in HAML code. > > > > > > > -- > > > > > 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]<haml%[email protected]> > <haml%[email protected]<haml%[email protected]> > >< > > > haml%[email protected]<haml%[email protected]> > <haml%[email protected]<haml%[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]<haml%[email protected]>< > haml%[email protected]<haml%[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] <haml%[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.
