Creating a Blank Rails 3.1 Templating Handler

孤街浪徒 提交于 2019-12-24 01:01:42

问题


What I want to do is make it just output the view itself, and ignore what Rails would normally think is embedded Ruby within the HTML.

For example:

<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>

I want an ActionView Template Handler to ignore all mentions of:

  • <%= homework.name %>
  • <%= homework.due %>
  • <%= current_question.contents %>
  • <%= current_question.answer %>

More specifically, it should ignore any tags starting with <% and ending with %>

If you need more info check out http://pastie.org/private/epsxnapldho6co2y0indg


回答1:


Here you go https://gist.github.com/1144297

And use .html.lifo extensions for your templates.



来源:https://stackoverflow.com/questions/7049039/creating-a-blank-rails-3-1-templating-handler

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!