Defining a class inside a .haml file and then using haml_tag, haml_concat from it?
I'm defining a class within Haml, and I'd like to be able to use the Haml helpers within this class. For example:
- class Whatever
- def self.write
- haml_concat "something"
- Whatever.write
Ideally, Whatever.write would output "something" to the template, but it simply fails with undefined method 'haml_concat' for Haml::Engine::Whatever:Class.
Full stacktrace: haml_test.haml:5:in `write': undefined method `haml_concat' for Haml::Engine::Whatever:Class (NoMethodError)
from haml_test.haml:8:in `block in render'
from /home/fraser/.rvm/gems/ruby-1.9.3-p125/gems/haml-3.1.4/lib/haml/engine.rb:191:in `eval'
from /home/fraser/.rvm/gems/ruby-1.9.3-p125/gems/haml-3.1.4/lib/haml/engine.rb:191:in `render'
from /home/fraser/.rvm/gems/ruby-1.9.3-p125/gems/haml-3.1.4/lib/haml/exec.rb:281:in `process_result'
from /home/fraser/.rvm/gems/ruby-1.9.3-p125/gems/haml-3.1.4/lib/haml/exec.rb:41:in `parse'
from /home/fraser/.rvm/gems/ruby-1.9.3-p125/gems/haml-3.1.4/lib/haml/exec.rb:21:in `parse!'
from /home/fraser/.rvm/gems/ruby-1.9.3-p125/gems/haml-3.1.4/bin/haml:9:in `<top (required)>'
from /home/fraser/.rvm/gems/ruby-1.9.3-p125/bin/haml:19:in `load'
from /home/fraser/.rvm/gems/ruby-1.9.3-p125/bin/haml:19:in `<main>'
How can I get this to work properly? I've tried using both extend and include Haml::Helpers, but they both fail too. Any ideas?
You received this message because you are subscribed to the Google Groups "Haml" group.
To view this discussion on the web visit https://groups.google.com/d/msg/haml/-/C_YAfyZH-W0J.
To post to this group, send email to haml-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to haml+unsubscribe <at> googlegroups.com.
For more options, visit this group at http://groups.google.com/group/haml?hl=en.
RSS Feed