I'm using Haml, simple_form, and blueprint CSS and I want to create a
form helper to make coding form fields a bit easier. I've already got
this working using a partial, but I thought it would be better to
generate all the code in the helper.
My idea was to generate a string of Haml code in the helper, then call
the Haml engine / insert the code into the template. The following is
the data I want Haml'd, as generated by the helper:
.span-2
=f.label :drivers_name, "Driver:", :class => 'form_label'
.span-10
=f.input :drivers_name, :label=>false, :input_html=>{ :class =>
'form_field' }
(f is the form builder provided by simple_form.)
I can generate the string with the no problems, but I don't know how
to (or if I can) insert this text into the template so that Haml will
parse and include it in the document.
I thought of initializing a new engine and then including the result
in the output buffer, using
Haml::Engine.new(string)
as a starting point, but that eventually errors out with "variable or
method 'f' not defined".
I tried initializing a new Engine and then parsing the string
directly
e = Haml::Engine.new(string)
s = e.send('parse')
but I get the error
undefined method `tabs' for nil:NilClass
I tried a simple concat(string), but all that did was output the
string to the view [concat_with_haml() returned a 'not defined'
error]. Checking in with string.is_haml? I learned that the above
string is not considered to be Haml at all...?!
I figure I'm completely down the rabbit hole -- what am I missing
here?
Thanks...jon
--
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.