Skip to content

Commit 904467f

Browse files
committed
Upgrade Papercraft to version 3.0
1 parent 506072a commit 904467f

5 files changed

Lines changed: 16 additions & 9 deletions

File tree

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
- Fix tests
2+
13
# 0.24 2025-10-08
24

35
- Use gem.coop in Gemfile

cmd/setup/template/site/site/articles/cage.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
' sile', 'N', 'ce?',
1414
]
1515

16-
export layout.apply {
16+
export Papercraft.apply(layout) {
1717
article(class: 'mesostic') {
1818
h2 'For William McN. who studied with Ezra Pound'
1919

cmd/setup/template/site/site/index.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
layout = import('_layout/default')
22

3-
export layout.apply {
3+
export Papercraft.apply(layout) {
44
h1 'Hello from Syntropy'
55
p {
66
span "Here's an "

lib/syntropy/app.rb

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -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(

syntropy.gemspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ Gem::Specification.new do |s|
2323

2424
s.add_dependency 'extralite', '2.13'
2525
s.add_dependency 'json', '2.13.2'
26-
s.add_dependency 'papercraft', '2.19'
26+
s.add_dependency 'papercraft', '3.0'
2727
s.add_dependency 'qeweney', '0.24'
2828
s.add_dependency 'tp2', '0.19'
2929
s.add_dependency 'uringmachine', '0.18'

0 commit comments

Comments
 (0)