papercraft 1.1 → 1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +9 -0
- data/README.md +33 -1
- data/lib/papercraft/compiler.rb +205 -370
- data/lib/papercraft/compiler_old.rb +701 -0
- data/lib/papercraft/extension_proxy.rb +0 -2
- data/lib/papercraft/extensions/soap.rb +0 -4
- data/lib/papercraft/html.rb +12 -11
- data/lib/papercraft/json.rb +8 -8
- data/lib/papercraft/renderer.rb +30 -2
- data/lib/papercraft/tags.rb +48 -48
- data/lib/papercraft/template.rb +32 -6
- data/lib/papercraft/version.rb +1 -1
- data/lib/papercraft/xml.rb +1 -1
- data/lib/papercraft.rb +2 -2
- metadata +33 -18
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4271050e1f7275fc148ae328a83d5e3357b908d47c0fd9817d3d3560def20a44
|
4
|
+
data.tar.gz: 723b2f6cbd79e3f7f979caa7411fc4819f6a4cf62b68089095a0e0c967d26913
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ab8a2a5fb35361deb86d4db69abb295f82a23fe17756e23dbe4f51a56e4af56db64966d391133750f40c279be3153b4005bbb005289a678908b365a2bd5bdf5f
|
7
|
+
data.tar.gz: 6bd0ffe0f793c87ad37fab7691e1d915f4b29b049a8fc1a69912550c1777e20ade9bc178b88d5812579a5abe986d46df1e98704692100fdc41e40b59ee5e2c5d
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -72,10 +72,11 @@ hello.render('world')
|
|
72
72
|
- [Adding Tags](#adding-tags)
|
73
73
|
- [Tag and Attribute Formatting](#tag-and-attribute-formatting)
|
74
74
|
- [Escaping Content](#escaping-content)
|
75
|
-
- [Direct Iteration]
|
75
|
+
- [Direct Iteration](#direct-iteration)
|
76
76
|
- [Template Parameters](#template-parameters)
|
77
77
|
- [Template Logic](#template-logic)
|
78
78
|
- [Template Blocks](#template-blocks)
|
79
|
+
- [Template Fragments](#template-fragments)
|
79
80
|
- [Plain Procs as Templates](#plain-procs-as-templates)
|
80
81
|
- [Template Composition](#template-composition)
|
81
82
|
- [Parameter and Block Application](#parameter-and-block-application)
|
@@ -97,6 +98,8 @@ hello.render('world')
|
|
97
98
|
|
98
99
|
## Installing Papercraft
|
99
100
|
|
101
|
+
**Note**: Papercraft requires Ruby version 3.2 or newer.
|
102
|
+
|
100
103
|
Using bundler:
|
101
104
|
|
102
105
|
```ruby
|
@@ -381,6 +384,35 @@ page = Papercraft.html {
|
|
381
384
|
page.render { h1 'hi' }
|
382
385
|
```
|
383
386
|
|
387
|
+
## Template Fragments
|
388
|
+
|
389
|
+
Template fragments allow rendering specific parts of a template, instead of the
|
390
|
+
entire template. For example, you can define a template for a web page that
|
391
|
+
includes a form, but may want to render just the form. Instead of extracting the
|
392
|
+
code and putting it into a separate template, you can use template fragments to
|
393
|
+
render just that part of that template:
|
394
|
+
|
395
|
+
```ruby
|
396
|
+
page = Papercraft.html {
|
397
|
+
div {
|
398
|
+
h1 'Page title'
|
399
|
+
p 'Some text'
|
400
|
+
}
|
401
|
+
div(id: 'my-form') {
|
402
|
+
fragment(:form) {
|
403
|
+
form {
|
404
|
+
input(name: 'email')
|
405
|
+
button 'OK'
|
406
|
+
}
|
407
|
+
}
|
408
|
+
}
|
409
|
+
}
|
410
|
+
page.render_fragment(:form)
|
411
|
+
```
|
412
|
+
|
413
|
+
For more information on how to use template fragments, see the [HTMX
|
414
|
+
article](https://htmx.org/essays/template-fragments/).
|
415
|
+
|
384
416
|
## Plain Procs as Templates
|
385
417
|
|
386
418
|
With Papercraft you can write a template as a plain Ruby proc, and later render
|