问题描述:

I'm using CodeRay and Haml to do syntax highlighting on some pages, and I write a lot of Ruby code. The problem is when I have something like this:

%pre

%code.language-ruby

:preserve

def hello(name)

puts "Hello #{name}!"

end

I keep getting errors because Haml keeps trying to evaluate the name variable inside the string, the #{var} syntax is a pretty common idiom in Ruby code and there aremany places where it is used, but I cannot use syntax highlighting of those codes because Haml wants to evaluate those variables inside the string.

Is there a way to tell Haml to not do that in some places?

网友答案:

Is there a way to tell Haml to not do that in some places?

By escaping the #:

puts "Hello \#{name}!" 
相关阅读:
Top