p2 2.10 → 2.11

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: 14c5c67f786953f8783be2cb53cb1eb4ad54be9f1ce769ce340cdc07d45b7a52
4
- data.tar.gz: 1788cf26c810fa3f4d47b6db4b0de149b223e47d6a8356af7dea580190664da9
3
+ metadata.gz: f9f7d2a86ea17670a7bcc69301db096ec2a2b667c7eb8f2c0df1ac28178eb823
4
+ data.tar.gz: 6dd4d03825d1a881fd7b721fea58af43b7c2f2c68f7ceb8bd8031a2fbfdab0de
5
5
  SHA512:
6
- metadata.gz: c898b73cbfeffcc1227bc15889d43e78dd03f745a9aee584767f4e8c22ae25d698190454c5cea9600735dddcc2da91a95fb7324b5cf906ef19824ba3dce7020c
7
- data.tar.gz: 6575f62f6158438bc95bea56d60d0f6fe4e11b1e45269584f6a644ffcd3d647e20bd712a869a556d882c4ff00a74a93f1bdefb5e8fe759787588bae9b3ba4abb
6
+ metadata.gz: 6cf0579fe72241ae904f417d1fd2f6e97ef347d8a3106b7069c232b8332440ef3eea5dc8b7c059516d3ad17903d207941d3e4c795768943950295fd345304248
7
+ data.tar.gz: 0b44037b06cc328543ed6809a5f5c0b675318902fcb36800559d1b100bf190f42e56d9249905a0ee50dd59cf0006a3fb4f17a31dcff10d6d86b70b9608d31842
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ # 2.11 2025-09-11
2
+
3
+ - Add mode param to `P2::Template` wrapper class
4
+
1
5
  # 2.10 2025-09-11
2
6
 
3
7
  - Add support for rendering XML, implement `Proc#render_xml`
data/lib/p2/template.rb CHANGED
@@ -4,10 +4,25 @@ module P2
4
4
  # Template wrapper class. This class can be used to distinguish between P2
5
5
  # templates and other kinds of procs.
6
6
  class Template
7
- attr_reader :proc
8
- def initialize(proc) = @proc = proc
9
- def render(*, **, &) = @proc.render(*, **, &)
10
- def apply(*, **, &) = Template.new(@proc.apply(*, **, &))
11
- def compiled_proc = @proc.compiled_proc
7
+ attr_reader :proc, :mode
8
+
9
+ # @param proc [Proc] template proc
10
+ # @param mode [Symbol] mode (:html, :xml)
11
+ def initialize(proc, mode: :html)
12
+ @proc = proc
13
+ @mode = mode
14
+ end
15
+
16
+ def render(*, **, &)
17
+ (mode == :xml) ? @proc.render_xml(*, **, &) : @proc.render(*, **, &)
18
+ end
19
+
20
+ def apply(*, **, &)
21
+ Template.new(@proc.apply(*, **, &), mode: @mode)
22
+ end
23
+
24
+ def compiled_proc
25
+ @proc.compiled_proc(mode: @mode)
26
+ end
12
27
  end
13
28
  end
data/lib/p2/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module P2
4
- VERSION = '2.10'
4
+ VERSION = '2.11'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: p2
3
3
  version: !ruby/object:Gem::Version
4
- version: '2.10'
4
+ version: '2.11'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sharon Rosner