rabl 0.1.2 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.md +19 -0
- data/lib/rabl/template.rb +1 -1
- data/lib/rabl/version.rb +1 -1
- metadata +2 -2
data/README.md
CHANGED
@@ -175,6 +175,25 @@ You can also extend other rabl templates while constructing child nodes to reduc
|
|
175
175
|
|
176
176
|
Using partials and inheritance can significantly reduce code duplication in your templates.
|
177
177
|
|
178
|
+
### Deep Nesting ###
|
179
|
+
|
180
|
+
In APIs, you can often need to construct 2nd or 3rd level nodes. Let's suppose we have a 'quiz' model that has many 'questions'
|
181
|
+
and then each question has many 'answers'. We can display this hierarchy in RABL quite easily:
|
182
|
+
|
183
|
+
# app/views/quizzes/show.json.rabl
|
184
|
+
object @quiz
|
185
|
+
attribute :title
|
186
|
+
child :questions do
|
187
|
+
attribute :caption
|
188
|
+
child :answers do
|
189
|
+
# Use inheritance to reduce duplication
|
190
|
+
extends "answers/item"
|
191
|
+
end
|
192
|
+
end
|
193
|
+
|
194
|
+
This will display the quiz object with nested questions and answers as you would expect with a quiz node, and embedded questions and answers.
|
195
|
+
Note that RABL can be nested arbitrarily deep within child nodes to allow for these representations to be defined.
|
196
|
+
|
178
197
|
## Issues ##
|
179
198
|
|
180
199
|
Check out the [Issues](https://github.com/nesquena/rabl/issues) tab for a full list:
|
data/lib/rabl/template.rb
CHANGED
data/lib/rabl/version.rb
CHANGED
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: rabl
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.1.
|
5
|
+
version: 0.1.3
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Nathan Esquenazi
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2011-04-
|
13
|
+
date: 2011-04-20 00:00:00 -07:00
|
14
14
|
default_executable:
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|