【问题标题】:Creating a Blank Rails 3.1 Templating Handler创建一个空白 Rails 3.1 模板处理程序
【发布时间】:2011-10-26 07:35:07
【问题描述】:

我想做的是让它只输出视图本身,而忽略 Rails 通常认为的 HTML 中嵌入的 Ruby。

例如:

<div class="current">
  <div class="question">
   <h3 id="homework_name"><%= homework.name %><h3 id="due">Due <%= homework.due %></h3></h3>
    <h2 class="title">The Question:</h2>
    <p id="question_contents"class="contents"><%= current_question.contents</p>
  </div>
  <div class="answer">
    <h2 class="title">Your Answer:</h2>
    <textarea class="contents" id="student_answer"><%= current_question.answer %></textarea>
  </div>
</div>

我希望 ActionView 模板处理程序忽略所有提及:

  • &lt;%= homework.name %&gt;
  • &lt;%= homework.due %&gt;
  • &lt;%= current_question.contents %&gt;
  • &lt;%= current_question.answer %&gt;

更具体地说,它应该忽略任何以&lt;% 开头并以%&gt; 结尾的标签

如果您需要更多信息,请查看http://pastie.org/private/epsxnapldho6co2y0indg

【问题讨论】:

    标签: markup ruby-on-rails-3.1 templating actionview


    【解决方案1】:

    给你https://gist.github.com/1144297

    并为您的模板使用 .html.lifo 扩展名。

    【讨论】:

      猜你喜欢
      • 2011-10-25
      • 1970-01-01
      • 1970-01-01
      • 2011-10-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-11-25
      相关资源
      最近更新 更多