@@ -250,14 +250,17 @@ def markdown_route_proc(route)
250250 def render_markdown ( route )
251251 atts , md = Syntropy . parse_markdown_file ( route [ :target ] [ :fn ] , @env )
252252
253+ layout = compute_markdown_layout ( route , atts )
254+ Papercraft . html ( layout , md :, **atts )
255+ end
256+
257+ def compute_markdown_layout ( route , atts )
253258 if ( layout = atts [ :layout ] )
254259 route [ :applied_layouts ] ||= { }
255- proc = route [ :applied_layouts ] [ layout ] ||= markdown_layout_template ( layout )
256- html = proc . render ( md :, **atts )
260+ route [ :applied_layouts ] [ layout ] ||= markdown_layout_template ( layout )
257261 else
258- html = default_markdown_layout_template . render ( md : , ** atts )
262+ default_markdown_layout_template
259263 end
260- html
261264 end
262265
263266 # Returns a markdown template based on the given layout.
@@ -267,7 +270,7 @@ def render_markdown(route)
267270 def markdown_layout_template ( layout )
268271 @layouts ||= { }
269272 template = @module_loader . load ( "_layout/#{ layout } " )
270- @layouts [ layout ] = template . apply { |md :, **| markdown ( md ) }
273+ @layouts [ layout ] = Papercraft . apply ( template ) { |md :, **| markdown ( md ) }
271274 end
272275
273276 # Returns the default markdown layout, which renders to HTML and includes a
@@ -324,7 +327,9 @@ def papercraft_template_proc(template)
324327 mime_type = xml_mode ? 'text/xml; charset=UTF-8' : 'text/html; charset=UTF-8'
325328 headers = { 'Content-Type' => mime_type }
326329
327- get_proc = xml_mode ? -> { [ template . render_xml , headers ] } : -> { [ template . render , headers ] }
330+ get_proc = xml_mode ?
331+ -> { [ Papercraft . xml ( template ) , headers ] } :
332+ -> { [ Papercraft . html ( template ) , headers ] }
328333
329334 -> ( req ) {
330335 req . respond_by_http_method (
0 commit comments