@@ -47,7 +47,7 @@ pub struct SiteInfo {
47
47
#[ derive( Serialize ) ]
48
48
pub struct TemplateContext {
49
49
request : BTreeMap < String , String > ,
50
- page : PageValues ,
50
+ page : Content ,
51
51
site : SiteValues ,
52
52
/// A copy of the environment variables
53
53
///
@@ -69,26 +69,7 @@ pub struct TemplateContext {
69
69
#[ derive( Serialize ) ]
70
70
pub struct SiteValues {
71
71
info : SiteInfo ,
72
- pages : BTreeMap < String , PageValues > ,
73
- }
74
-
75
- /// The structured values sent to the template renderer.
76
- /// The body should be legal HTML that can be inserted within the <body> tag.
77
- #[ derive( Serialize , Deserialize ) ]
78
- pub struct PageValues {
79
- pub head : Head ,
80
- pub body : String ,
81
- pub published : bool ,
82
- }
83
-
84
- impl From < Content > for PageValues {
85
- fn from ( c : Content ) -> Self {
86
- PageValues {
87
- body : c. body ,
88
- head : c. head ,
89
- published : c. published ,
90
- }
91
- }
72
+ pages : BTreeMap < String , Content > ,
92
73
}
93
74
94
75
/// Renderer can execute a handlebars template and render the results into HTML.
@@ -190,14 +171,13 @@ impl<'a> Renderer<'a> {
190
171
}
191
172
192
173
/// Given values and a site object, render a template.
193
- pub fn render_template < T : Into < PageValues > > (
174
+ pub fn render_template (
194
175
& self ,
195
- values : T ,
176
+ content : Content ,
196
177
info : SiteInfo ,
197
178
request : HeaderMap ,
198
179
) -> anyhow:: Result < String > {
199
- let page: PageValues = values. into ( ) ;
200
- let tpl = page
180
+ let tpl = content
201
181
. head
202
182
. template
203
183
. clone ( )
@@ -210,7 +190,7 @@ impl<'a> Renderer<'a> {
210
190
}
211
191
212
192
let ctx = TemplateContext {
213
- page,
193
+ page : content ,
214
194
request : request_headers,
215
195
site : SiteValues {
216
196
// Right now, we literally include ALL OF THE CONTENT in its rendered
@@ -279,8 +259,8 @@ fn pages_helper(
279
259
///
280
260
/// It should be assumed that all data passed into this function will be visible to the
281
261
/// end user.
282
- pub fn error_values ( title : & str , msg : & str ) -> PageValues {
283
- PageValues {
262
+ pub fn error_values ( title : & str , msg : & str ) -> Content {
263
+ Content {
284
264
head : Head {
285
265
title : title. to_string ( ) ,
286
266
date : Some ( chrono:: Utc :: now ( ) ) ,
0 commit comments