创建一个空白的Rails 3.1模板处理程序 [英] Creating a Blank Rails 3.1 Templating Handler

查看:73
本文介绍了创建一个空白的Rails 3.1模板处理程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想做的是使其仅输出视图本身,而忽略Rails通常认为在HTML中嵌入Ruby的东西.

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.

例如:

<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模板处理程序忽略以下所有提及:

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

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

更具体地说,它应该忽略所有以<%开始并以%>

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

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

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

推荐答案

在这里您 https://gist.github .com/1144297

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

And use .html.lifo extensions for your templates.

这篇关于创建一个空白的Rails 3.1模板处理程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆