简体   繁体   English

如何在 Rails 的每个 html.erb 文件中插入 erb 绝对路径?

[英]How do you insert erb absolute paths in each html.erb file in Rails?

I want to make the rendered html known about what erb files were rendered like below for debugging use in development in Rails.我想让渲染的 html 知道渲染了哪些 erb 文件,如下所示,以便在 Rails 开发中调试使用。

<html>
  <!-- /RAILS_ROOT/app/views/layouts/application.html.erb -->

  <body>
    <!-- /RAILS_ROOT/app/views/entries/index.html.erb -->
    <h2>hello</h2>
  </body>
</html>

For now, I am enforced to insert one line comment onto each erb file as below, but the work is not DRY and very painful.现在,我被迫在每个 erb 文件中插入一行注释,如下所示,但这项工作并不枯燥且非常痛苦。

<!-- <%= __FILE__ if Rails.env.development? %> -->

My Questions are:我的问题是:

  1. Does any gem support this issue?有任何 gem 支持这个问题吗?
  2. If 1 is no or not good enough, can you insert the comment by monkey-patching the Rails code?如果 1 不是或不够好,您可以通过对 Rails 代码进行猴子修补来插入注释吗?

`That's how you go from page to page. `这就是你如何一页一页地翻阅。

In plain HTML, you create a link like this:在纯 HTML 中,您可以创建如下链接:

<a href="/ruby-book">Improve Your Ruby Skills</a>

But in Rails that would look like this:(html.erg)但在 Rails 中,它看起来像这样:(html.erg)

<%= link_to "Improve Your Ruby Skills", "/ruby-book" %> <%= link_to "提高你的 Ruby 技能", "/ruby-book" %>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM