Stop me if I am wrong, but Haml isn't for defining classes. It is for 
replacing HTML. You can use inline Ruby, but I don't use Haml to define 
Ruby classes. I consider it to be for the View portion of the MVC model.

On Sunday, May 20, 2012 11:49:29 AM UTC-4, Fraser Murray wrote:
>
> 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/-/M1wtHTlO1ysJ.
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.

Reply via email to