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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 41c765213957fc2681e2f4cd7d94e7580e45394128d61a800349aa6e848c6b00
4
- data.tar.gz: 5c2b0a91c3d4c744db20536d08ae741a07dab3a9cfc2c5fa790ea987224b5c7e
3
+ metadata.gz: 4271050e1f7275fc148ae328a83d5e3357b908d47c0fd9817d3d3560def20a44
4
+ data.tar.gz: 723b2f6cbd79e3f7f979caa7411fc4819f6a4cf62b68089095a0e0c967d26913
5
5
  SHA512:
6
- metadata.gz: cf87f3ae1bcf718ad7b03e5b1b895cd8065e2aee72f7044cf0fb822db029477aa98297b8caf66d9e3db1ee664d9e42a954afb203f856fa6f190765defe5139e1
7
- data.tar.gz: bfd2847daa9f2d9be7a0aa7e0adee170771e3fcdd6ca0ad407478f7b5bff2848b63639d21c26d1b9d040ac44b741d9032ac24742e839e19f1327d81ffd88e901
6
+ metadata.gz: ab8a2a5fb35361deb86d4db69abb295f82a23fe17756e23dbe4f51a56e4af56db64966d391133750f40c279be3153b4005bbb005289a678908b365a2bd5bdf5f
7
+ data.tar.gz: 6bd0ffe0f793c87ad37fab7691e1d915f4b29b049a8fc1a69912550c1777e20ade9bc178b88d5812579a5abe986d46df1e98704692100fdc41e40b59ee5e2c5d
data/CHANGELOG.md CHANGED
@@ -1,3 +1,12 @@
1
+ ## 1.3 2024-12-16
2
+
3
+ - Update dependencies
4
+
5
+ ## 1.2 2023-08-21
6
+
7
+ - Update dependencies
8
+ - Implement template fragments
9
+
1
10
  ## 1.1 2023-07-03
2
11
 
3
12
  - Add direct iteration using the `_for` attribute
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][#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