aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYves Senn <yves.senn@gmail.com>2015-09-24 08:36:42 +0200
committerYves Senn <yves.senn@gmail.com>2015-09-24 08:38:17 +0200
commit8516d76c621bb679666f6c452a052c84feed11c4 (patch)
tree29ba48da8be2047e275ef92dc130572e2adcc8d8
parentc5481d8af3ee8ab32489799362c9e86b6efac099 (diff)
parent961779997cb28750d52d6186b41c29c33677ae0f (diff)
downloadrails-8516d76c621bb679666f6c452a052c84feed11c4.tar.gz
rails-8516d76c621bb679666f6c452a052c84feed11c4.tar.bz2
rails-8516d76c621bb679666f6c452a052c84feed11c4.zip
Merge pull request #21740 from cllns/add-jbuilder-notes
[ci skip] [Action View Overview Guide] Add note about Jbuilder
-rw-r--r--guides/source/action_view_overview.md33
1 files changed, 33 insertions, 0 deletions
diff --git a/guides/source/action_view_overview.md b/guides/source/action_view_overview.md
index 00c41a480e..76454e77c7 100644
--- a/guides/source/action_view_overview.md
+++ b/guides/source/action_view_overview.md
@@ -147,6 +147,39 @@ xml.rss("version" => "2.0", "xmlns:dc" => "http://purl.org/dc/elements/1.1/") do
end
```
+#### Jbuilder
+[Jbuilder](https://github.com/rails/jbuilder) is a gem that's
+maintained by the Rails team and included in the default Rails Gemfile.
+It's similar to Builder, but is used to generate JSON, instead of XML.
+
+If you don't have it, you can add the following to your Gemfile:
+
+```ruby
+gem 'jbuilder'
+```
+
+A Jbuilder object named `json` is automatically made available to templates with
+a `.jbuilder` extension.
+
+Here is a basic example:
+
+```ruby
+json.name("Alex")
+json.email("alex@example.com")
+```
+
+would produce:
+
+```json
+{
+ "name": "Alex",
+ "email: "alex@example.com"
+}
+```
+
+See the [Jbuilder documention](https://github.com/rails/jbuilder#jbuilder) for
+more examples and information.
+
#### Template Caching
By default, Rails will compile each template to a method in order to render it. When you alter a template, Rails will check the file's modification time and recompile it in development mode.