Haml_tag does not return a single row

Hi, I tried to copy my old haml_tags, and it seems that they do not work for Rails 3.1rc4, or I'm doing something wrong. Can someone point me in the right direction?

def bonus_value_of(stat) bonus = current_user.character.send("bonus_#{stat}".to_sym) capture_haml do haml_tag :span, :class => "positive" do "+#{bonus}" end end end 

thats my code, which I call with

 = bonus_value_of(stat) 

and all I get is an empty space with a positive class, but no content (not even a plus)

this is mistake?

+4
source share
2 answers

Here is my version.

1. Your assistant should be in the controller assistant, and not in module Haml::Helper , as described in some article.

2.Use your assistant for this:

 def bonus_value_of(stat) bonus = current_user.character.send("bonus_#{stat}".to_sym) haml_tag :span, :class => "positive" do haml_concat "+#{bonus}" end end 

And then use it in your view as follows:

 - bonus_value_of(stat) 
+3
source

I just ran into this. I needed to pass range text as the second value of haml_tag .

 def bonus_value_of(stat) bonus = current_user.character.send("bonus_#{stat}".to_sym) capture_haml do haml_tag :span, "+#{bonus}", :class => "positive" end end 
+2
source

All Articles