File tree Expand file tree Collapse file tree 1 file changed +64
-0
lines changed Expand file tree Collapse file tree 1 file changed +64
-0
lines changed Original file line number Diff line number Diff line change @@ -110,3 +110,67 @@ This becomes:
110
110
}
111
111
}
112
112
```
113
+
114
+
115
+ ## Mixin
116
+
117
+ During preprocessing traversal, an implementation must resolve ` $mixin `
118
+ directives. An ` $mixin ` directive is an object consisting of the field
119
+ ` $mixin ` specifying resource by URI string. If there are additional fields in
120
+ the ` $mixin ` object, these fields override fields in the object which is loaded
121
+ from the ` $mixin ` URI.
122
+
123
+ The URI string must be resolved to an absolute URI using the link resolution
124
+ rules described previously. Implementations must support loading from ` file ` ,
125
+ ` http ` and ` https ` resources. The URI referenced by ` $mixin ` must be loaded
126
+ and recursively preprocessed as a Salad document. The external imported
127
+ document must inherit the context of the importing document, however the file
128
+ URI for processing the imported document must be the URI used to retrieve the
129
+ imported document. The ` $mixin ` URI must not include a document fragment.
130
+
131
+ Once loaded and processed, the ` $mixin ` node is replaced in the document
132
+ structure by the object or array yielded from the import operation.
133
+
134
+ URIs may reference document fragments which refer to specific an object in
135
+ the target document. This indicates that the ` $mixin ` node must be
136
+ replaced by only the object with the appropriate fragment identifier.
137
+
138
+ It is a fatal error if an import directive refers to an external resource
139
+ or resource fragment which does not exist or is not accessible.
140
+
141
+ ### Mixin example
142
+
143
+ mixin.yml:
144
+ ```
145
+ {
146
+ "hello": "world",
147
+ "carrot": "orange"
148
+ }
149
+
150
+ ```
151
+
152
+ parent.yml:
153
+ ```
154
+ {
155
+ "form": {
156
+ "bar": {
157
+ "$mixin": "mixin.yml"
158
+ "carrot": "cake"
159
+ }
160
+ }
161
+ }
162
+
163
+ ```
164
+
165
+ This becomes:
166
+
167
+ ```
168
+ {
169
+ "form": {
170
+ "bar": {
171
+ "hello": "world",
172
+ "carrot": "cake"
173
+ }
174
+ }
175
+ }
176
+ ```
You can’t perform that action at this time.
0 commit comments