List Info

Thread: Haml helper inside an extending class




Haml helper inside an extending class
country flaguser name
United States
2007-10-08 17:32:59
I'm trying to convert a form helper to HAML and running into
some
trouble.

http://pastie.caboo.se/
105101

Anyone see where I am going wrong?


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "Haml" group.
To post to this group, send email to hamlgooglegroups.com
To unsubscribe from this group, send email to
haml-unsubscribegooglegroups.com
For more options, visit this group at http://grou
ps.google.com/group/haml?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: Haml helper inside an extending class
country flaguser name
United States
2007-10-08 18:54:34
I'm not sure what's causing that. Could you try to find the
minimal code 
that still breaks? Preferably something I could test via
bin/haml?

- Nathan

pimpmaster wrote:
> I'm trying to convert a form helper to HAML and running
into some
> trouble.
>
> http://pastie.caboo.se/
105101
>
> Anyone see where I am going wrong?
>
>
> >
>
>   


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "Haml" group.
To post to this group, send email to hamlgooglegroups.com
To unsubscribe from this group, send email to
haml-unsubscribegooglegroups.com
For more options, visit this group at http://grou
ps.google.com/group/haml?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: Haml helper inside an extending class
country flaguser name
United States
2007-10-08 20:00:40
Does it break without the super? Without the open :p?

- Nathan

pimpmaster wrote:
> The culprit is here.. I have simplified a bit and this
still breaks
> with the same errors
>
> def self.create_tagged_field(method_name)
>   define_method(method_name) do |label, *args|
>     open :p do
>       super
>     end
>   end
> end
>
>
> >
>
>   


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "Haml" group.
To post to this group, send email to hamlgooglegroups.com
To unsubscribe from this group, send email to
haml-unsubscribegooglegroups.com
For more options, visit this group at http://grou
ps.google.com/group/haml?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: Haml helper inside an extending class
country flaguser name
United States
2007-10-08 19:58:53
The culprit is here.. I have simplified a bit and this still
breaks
with the same errors

def self.create_tagged_field(method_name)
  define_method(method_name) do |label, *args|
    open :p do
      super
    end
  end
end


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "Haml" group.
To post to this group, send email to hamlgooglegroups.com
To unsubscribe from this group, send email to
haml-unsubscribegooglegroups.com
For more options, visit this group at http://grou
ps.google.com/group/haml?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: Haml helper inside an extending class
country flaguser name
United States
2007-10-08 22:13:57
What about if you use "p" instead of the symbol
:p
?

On Oct 8, 2007, at 6:00 PM, Nathan Weizenbaum wrote:

>
> Does it break without the super? Without the open :p?
>
> - Nathan
>
> pimpmaster wrote:
>> The culprit is here.. I have simplified a bit and
this still breaks
>> with the same errors
>>
>> def self.create_tagged_field(method_name)
>>   define_method(method_name) do |label, *args|
>>     open :p do
>>       super
>>     end
>>   end
>> end
>>
>>
>>>
>>
>>
>
>
> >


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "Haml" group.
To post to this group, send email to hamlgooglegroups.com
To unsubscribe from this group, send email to
haml-unsubscribegooglegroups.com
For more options, visit this group at http://grou
ps.google.com/group/haml?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: Haml helper inside an extending class
country flaguser name
United States
2007-10-08 22:20:49
That shouldn't matter; that parameter is only used in string

interpolation, where it's implicitly converted to a string.

- Nathan

s.ross wrote:
> What about if you use "p" instead of the
symbol :p
> ?
>
> On Oct 8, 2007, at 6:00 PM, Nathan Weizenbaum wrote:
>
>   
>> Does it break without the super? Without the open
:p?
>>
>> - Nathan
>>
>> pimpmaster wrote:
>>     
>>> The culprit is here.. I have simplified a bit
and this still breaks
>>> with the same errors
>>>
>>> def self.create_tagged_field(method_name)
>>>   define_method(method_name) do |label, *args|
>>>     open :p do
>>>       super
>>>     end
>>>   end
>>> end
>>>
>>>
>>>       
>>>       
>>     
>
>
> >
>
>   


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "Haml" group.
To post to this group, send email to hamlgooglegroups.com
To unsubscribe from this group, send email to
haml-unsubscribegooglegroups.com
For more options, visit this group at http://grou
ps.google.com/group/haml?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: Haml helper inside an extending class
country flaguser name
United States
2007-10-08 22:46:00
Oh, I bet I know what it is. I bet the issue is that you
don't have the 
Haml helpers in scope; it's trying to use Kernel#open rather
than 
Haml::Helpers#open.

I'm not sure how that form stuff gets access to the
ActionView instance, 
though.

- Nathan

pimpmaster wrote:
> It's breaking without super. Even trying something
simple like
>
> open :p, 'hello'
>
> breaks with the same error.
>
> One thing worth noting is that this method is inside of
a class which
> lives in a helper...does that affect antyhing?
>
>
> >
>
>   


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "Haml" group.
To post to this group, send email to hamlgooglegroups.com
To unsubscribe from this group, send email to
haml-unsubscribegooglegroups.com
For more options, visit this group at http://grou
ps.google.com/group/haml?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: Haml helper inside an extending class
country flaguser name
United States
2007-10-09 05:49:20
Okay scratch that idea. I was trying to create my own
abstracted form
helpers and realized that someone had already done a better
job in
plugin form:

http
://cssformbuilder.rubyforge.org/wiki/wiki.pl

There is only one problem here and that is with the textarea
tag. As
we know, Haml's indentation affects this tag contents unless
we
explicitly set it as:

~ textarea :description

This means that I have to somehow integrate that tilde
function into
the plugin. Here is the code that builds the HTML:

def process(field,options,tag_output)
  unless (extra=options[:extra]).nil?
    tag_extra="<span
style='float:left'>#</span>"
  else
    tag_extra=""
  end if
  input_field_id = "#{object_name}_#"
  label=options[:label]
  label= (field.to_s.humanize) if label.nil?
  s="<div class='form-field'>n"
  s << "  <label
for='#'>#{label.translate}</label>
n"
unless label==false
  s << "  # #n"
  s << "</div>n"
  s
end

Now, I'm not even gonna try to use the :open helpers here
because I
know it will just be the same problem. Basically I just have
2
questions

1. How does one get a method inside of a plugin to speak
Haml?
2. What is the best way to code this so that only textarea
gets the
tilde treatment?


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "Haml" group.
To post to this group, send email to hamlgooglegroups.com
To unsubscribe from this group, send email to
haml-unsubscribegooglegroups.com
For more options, visit this group at http://grou
ps.google.com/group/haml?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: Haml helper inside an extending class
country flaguser name
United States
2007-10-09 05:54:29
AGH!!

Please disregard my last post. Setting the tilde within the
form
partial seems to be working.

Although I am still curious if/how one could use HAML
helpers outside
the confines of a helper file.


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "Haml" group.
To post to this group, send email to hamlgooglegroups.com
To unsubscribe from this group, send email to
haml-unsubscribegooglegroups.com
For more options, visit this group at http://grou
ps.google.com/group/haml?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: Haml helper inside an extending class
country flaguser name
United States
2007-10-09 06:11:06
Another interesting challenge as I tweak my custom
generators:

<% for attribute in attributes -%>
<% if attribute.field_type == "text_area"
-%>
~ <%= attribute.field_type %> :<%= attribute.name
%>
<% else -%>
= f.<%= attribute.field_type %> :<%= attribute.name
%>
<% end -%>
<% end -%>

The above condition is ignored and I can't figure out why.
The idea is
to always have the tilde on my textarea helpers.


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "Haml" group.
To post to this group, send email to hamlgooglegroups.com
To unsubscribe from this group, send email to
haml-unsubscribegooglegroups.com
For more options, visit this group at http://grou
ps.google.com/group/haml?hl=en
-~----------~----~----~----~------~----~------~--~---


[1-10] [11]

about | contact  Other archives ( Real Estate discussion Medical topics )