提交 c6af3bad 编写于 作者: Z Zachary Scott

Merge pull request #16408 from aditya-kapoor/add-doc-ERB-escape

[ci skip] add note about the ERB escape in generator docs
...@@ -8,6 +8,7 @@ After reading this guide, you will know: ...@@ -8,6 +8,7 @@ After reading this guide, you will know:
* How to see which generators are available in your application. * How to see which generators are available in your application.
* How to create a generator using templates. * How to create a generator using templates.
* How Rails searches for generators before invoking them. * How Rails searches for generators before invoking them.
* How Rails internally generates Rails code from the templates.
* How to customize your scaffold by creating new generators. * How to customize your scaffold by creating new generators.
* How to customize your scaffold by changing generator templates. * How to customize your scaffold by changing generator templates.
* How to use fallbacks to avoid overwriting a huge set of generators. * How to use fallbacks to avoid overwriting a huge set of generators.
...@@ -340,6 +341,20 @@ end ...@@ -340,6 +341,20 @@ end
If you generate another resource, you can see that we get exactly the same result! This is useful if you want to customize your scaffold templates and/or layout by just creating `edit.html.erb`, `index.html.erb` and so on inside `lib/templates/erb/scaffold`. If you generate another resource, you can see that we get exactly the same result! This is useful if you want to customize your scaffold templates and/or layout by just creating `edit.html.erb`, `index.html.erb` and so on inside `lib/templates/erb/scaffold`.
Many scaffold templates in Rails are written in ERB tags which needs to be escaped, so that the output is a valid ERB code, that can be used correctly in Rails app.
The following code in one of the generator file,
```ruby
<%%= stylesheet_include_tag :application %>
```
when passed through the generator, would generate the following output.
```ruby
<%= stylesheet_include_tag :application %>
```
Adding Generators Fallbacks Adding Generators Fallbacks
--------------------------- ---------------------------
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册