32
32
import org .springframework .util .Assert ;
33
33
34
34
/**
35
- * Public API for HTML rendering of a collection of fragments each with a view
36
- * and independent model. For use with frontends technologies such as
35
+ * Public API to render HTML fragments. A fragment is a portion of an HTML page.
36
+ * Normally HTML is rendered with a single model and view. This API allows
37
+ * using multiple model and view pairs, one for each HTML fragment.
38
+ *
39
+ * <p>For use with frontends technologies such as
37
40
* <a href="https://htmx.org/">htmx</a> where multiple page fragments may be
38
- * rendered in one response. Supported as a return value from Spring WebFlux
39
- * controller methods.
41
+ * rendered in one response.
40
42
*
41
- * <p>For full page rendering with a single model and view, use {@link Rendering}.
43
+ * <p>Supported as a return value from annotated controller methods.
44
+ * For full page rendering with a single model and view, use {@link Rendering}.
42
45
*
43
46
* @author Rossen Stoyanchev
44
47
* @since 6.2
@@ -63,19 +66,19 @@ public interface FragmentsRendering {
63
66
64
67
65
68
/**
66
- * Create a builder and add a fragment with a view name and a model .
67
- * @param viewName the name of the view for the fragment
68
- * @param model attributes for the fragment in addition to model
69
- * attributes inherited from the model for the request
69
+ * Create a builder with one HTML fragment .
70
+ * @param viewName the view name for the fragment
71
+ * @param model attributes for the fragment, in addition to attributes from the
72
+ * shared model for the request
70
73
* @return this builder
71
74
*/
72
75
static Builder with (String viewName , Map <String , Object > model ) {
73
76
return withCollection (List .of (Fragment .create (viewName , model )));
74
77
}
75
78
76
79
/**
77
- * Variant of {@link # with(String, Map)} with a view name only, but also
78
- * inheriting model attributes from the shared model for the request.
80
+ * Create a builder with one HTML fragment, also inheriting attributes from
81
+ * the shared model for the request.
79
82
* @param viewName the name of the view for the fragment
80
83
* @return this builder
81
84
*/
@@ -84,8 +87,8 @@ static Builder with(String viewName) {
84
87
}
85
88
86
89
/**
87
- * Variant of {@link # with(String, Map)} with a collection of fragments.
88
- * @param fragments the fragments to add; each fragment also inherits model
90
+ * Create a builder with multiple HTML fragments.
91
+ * @param fragments the fragments to add; each fragment also inherits
89
92
* attributes from the shared model for the request
90
93
* @return the created builder
91
94
*/
@@ -94,7 +97,7 @@ static Builder withCollection(Collection<Fragment> fragments) {
94
97
}
95
98
96
99
/**
97
- * Variant of {@link #with(String, Map)} with a {@link Publisher} of fragments.
100
+ * Create a builder with a {@link Publisher} of fragments.
98
101
* @param fragmentsPublisher the fragments to add; each fragment also
99
102
* inherits model attributes from the shared model for the request
100
103
* @return the created builder
@@ -148,25 +151,24 @@ interface Builder {
148
151
Builder headers (Consumer <HttpHeaders > headersConsumer );
149
152
150
153
/**
151
- * Add a fragment with a view name and a model .
152
- * @param viewName the name of the view for the fragment
153
- * @param model attributes for the fragment in addition to model
154
- * attributes inherited from the model for the request
154
+ * Add an HTML fragment .
155
+ * @param viewName the view name for the fragment
156
+ * @param model fragment attributes in addition to attributes from the
157
+ * shared model for the request
155
158
* @return this builder
156
159
*/
157
160
Builder fragment (String viewName , Map <String , Object > model );
158
161
159
162
/**
160
- * Variant of {@link #fragment(String, Map)} with a view name only, where
161
- * the fragment model also inherits model attributes from the shared
163
+ * Add an HTML fragment. The fragment will use attributes from the shared
162
164
* model for the request.
163
- * @param viewName the name of the view for the fragment
165
+ * @param viewName the view name for the fragment
164
166
* @return this builder
165
167
*/
166
168
Builder fragment (String viewName );
167
169
168
170
/**
169
- * Variant of {@link # fragment(String, Map)} with a {@link Fragment} .
171
+ * Add an HTML fragment.
170
172
* @param fragment the fragment to add
171
173
* @return this builder
172
174
*/
0 commit comments