使用苛刻的生成代码

时间:2010-06-20 12:35:07

标签: ruby-on-rails haml

我在@snippet.code中有代码,我想用harsh突出显示:

:harsh
  #!harsh theme = lazy
  = @snippet.code

但是,这只是突出显示@snippet.code,因此输出为:

<pre class="lazy"><span class="Keyword">=</span> <span class="Variable"><span class="Variable">@</span>snippet</span>.code&#x000A;</pre>

如何在生成的代码中使用Harsh?感谢

1 个答案:

答案 0 :(得分:0)

您需要打印出@ snippet.code

的内容

了解您正在使用的模板引擎会有所帮助。尝试:

:harsh
  #!harsh theme = lazy
  <%= @snippet.code %>

如果erb在苛刻之前到达代码,这应该有用。