tags:

views:

48

answers:

1

how can I have in the second line the value of the variable file instead of both strings file?

- files.each do |file| 
  %a(href="test?run=file")click file 
+2  A: 
- files.each do |file|
  %a(href="test?run=file")
    click
    = file

=== UPDATED ===

- files.each do |file|
  %a(href="test?run=#{file}")
    click
    = file

or use link_to instead of %a

- files.each do |file|
  = link_to "test?run=#{file}" do
    click
    = file
PeterWong
@PeterWong: It seems to me that you missed second `|`. I was getting an error but using the closing `|` fixed that. I wanted to replace both strings file with the value of the variable value. Can I do that?
Radek
Updated answer. Sorry for the miss of second `|`, added it back :D
PeterWong
@PeterWong: exactly what I wanted. Thank you. Could you recommend any haml tutorial for me?
Radek
Instead of click and = file on separate lines, you can do "== click #{file}"
Jason Noble
@Jason Noble: what does the == do? Can I use this one line thing even if I want 'file' in bold but click not?
Radek
@Jason, thanks for pointing out the use of == :D. `== click #{file}` is the same as `= "click #{file}"`. I started learning haml for few days only. So if you want to output a line of string with rails variables, `==` should be better ^^|| But I don't think you could use `%strong` etc in the middle...
PeterWong
Radek, as Peter pointed out, == ... is equivalent to = "...". It says "this whole line is a double quoted string".
Jason Noble