p2 2.0 → 2.0.1

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: 37c651c3157074dde83015d5e4e6db8a44ef90b12a8dd890a585539e3eb80b4d
4
- data.tar.gz: 384d6a649bc089c24d578185f75a7e5a09b22825d70f1367e55b0e8a7f0e3cd8
3
+ metadata.gz: 9a0a95331ecb304e4fb0ae830d5c1f30a160a4ec9d26d86de8b22454fbef21e2
4
+ data.tar.gz: 49ecb084b5881d3f8287c4af46edfbf9b83930438baddafb3502ddf44b2a8b24
5
5
  SHA512:
6
- metadata.gz: 6565857078969d64aced3c864d295ca9d4627b08bff842eda2578d8759022ac78c3553b3feef99550efee9498a5f0a943ffae2ca12f5dd001162165101bad557
7
- data.tar.gz: d0b758535f27c4ec60dac2649d79504c01fcc3e021e318259ea475215cd3d62efec1e360a9529c2bdc6bc1068ed31c44d6339fd44e99aae1bcb4bd8eb97983e8
6
+ metadata.gz: 3b4aae65ebce0e4e87adf6e19e7c7731aa481dfeb3d6efb66c2ae345c704f828d0d2143a147e49f49061e0ad30c1b48209d198ffa9aaeca1cd743167257e297b
7
+ data.tar.gz: 6efe1aedca928c95a0102e1192c3406f8657c54536f18c0db741f86b8b365c9a178565171d7f5476f78ebb47b566a6d075c5dad674d6c4ae41fc995f603a0ce5
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## 2.0.1 2025-08-07
2
+
3
+ - Fix source map calculation
4
+
1
5
  ## 2.0 2025-08-07
2
6
 
3
7
  - Passes all HTML, compilation tests from Papercraft
data/README.md CHANGED
@@ -24,9 +24,9 @@
24
24
 
25
25
  ## What is P2?
26
26
 
27
- P2 is a templating engine for dynamically producing [HTML](#html-templates). P2
28
- templates are expressed as Ruby procs, leading to easier debugging, better
29
- protection against HTML/XML injection attacks, and better code reuse.
27
+ P2 is a templating engine for dynamically producing HTML. P2 templates are
28
+ expressed as Ruby procs, leading to easier debugging, better protection against
29
+ HTML injection attacks, and better code reuse.
30
30
 
31
31
  P2 templates can be composed in a variety of ways, facilitating the usage of
32
32
  layout templates, and enabling a component-oriented approach to building complex
@@ -37,11 +37,8 @@ making the data flow easy to follow and understand. P2 also lets developers
37
37
  create derivative templates using full or partial parameter application.
38
38
 
39
39
  P2 includes built-in support for rendering Markdown (using
40
- [Kramdown](https://github.com/gettalong/kramdown/)).
41
-
42
- P2 automatically escapes all text emitted in templates according to the template
43
- type. For more information see the section on [escaping
44
- content](#escaping-content).
40
+ [Kramdown](https://github.com/gettalong/kramdown/)). P2 also automatically
41
+ escapes all text emitted in templates.
45
42
 
46
43
  ```ruby
47
44
  require 'p2'
@@ -64,6 +61,16 @@ hello.render(name: 'world')
64
61
  #=> "<html><head><title>Title</title></head><body><h1>Hello, world!</h1></body></html>"
65
62
  ```
66
63
 
64
+ P2 features:
65
+
66
+ - Express HTML using plain Ruby procs.
67
+ - Automatic compilation for super-fast execution (up to 2X faster than ERB templates).
68
+ - Deferred rendering using `defer`.
69
+ - Template composition (for uses such as layouts).
70
+ - Automatic conversion of backtraces for exceptions occurring while rendering,
71
+ in order to point to the correct spot in the original template code.
72
+
73
+
67
74
  ## Table of Content
68
75
 
69
76
  - [Installing P2](#installing-p2)
data/lib/p2/compiler.rb CHANGED
@@ -235,6 +235,7 @@ module P2
235
235
  @binding = binding
236
236
  visit(ast)
237
237
  flush_html_parts!(semicolon_prefix: true)
238
+ update_source_map
238
239
 
239
240
  source_code = @buffer
240
241
  @buffer = +''
data/lib/p2/proc_ext.rb CHANGED
@@ -5,7 +5,7 @@ require_relative './compiler'
5
5
  # Extensions to the Proc class
6
6
  class ::Proc
7
7
  def compiled_code
8
- P2::TemplateCompiler.compile_to_code(self)
8
+ P2::TemplateCompiler.compile_to_code(self).last
9
9
  end
10
10
 
11
11
  def compiled?
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.0'
4
+ VERSION = '2.0.1'
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.0'
4
+ version: 2.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sharon Rosner
@@ -15,14 +15,14 @@ dependencies:
15
15
  requirements:
16
16
  - - "~>"
17
17
  - !ruby/object:Gem::Version
18
- version: 0.8.1
18
+ version: 0.8.2
19
19
  type: :runtime
20
20
  prerelease: false
21
21
  version_requirements: !ruby/object:Gem::Requirement
22
22
  requirements:
23
23
  - - "~>"
24
24
  - !ruby/object:Gem::Version
25
- version: 0.8.1
25
+ version: 0.8.2
26
26
  - !ruby/object:Gem::Dependency
27
27
  name: kramdown
28
28
  requirement: !ruby/object:Gem::Requirement
@@ -93,6 +93,20 @@ dependencies:
93
93
  - - "~>"
94
94
  - !ruby/object:Gem::Version
95
95
  version: 2.7.2
96
+ - !ruby/object:Gem::Dependency
97
+ name: tilt
98
+ requirement: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - "~>"
101
+ - !ruby/object:Gem::Version
102
+ version: 2.2.0
103
+ type: :development
104
+ prerelease: false
105
+ version_requirements: !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - "~>"
108
+ - !ruby/object:Gem::Version
109
+ version: 2.2.0
96
110
  email: sharon@noteflakes.com
97
111
  executables: []
98
112
  extensions: []
@@ -111,9 +125,8 @@ homepage: http://github.com/digital-fabric/p2
111
125
  licenses:
112
126
  - MIT
113
127
  metadata:
114
- source_code_uri: https://github.com/digital-fabric/p2
115
- documentation_uri: https://www.rubydoc.info/gems/p2
116
128
  homepage_uri: https://github.com/digital-fabric/p2
129
+ documentation_uri: https://www.rubydoc.info/gems/p2
117
130
  changelog_uri: https://github.com/digital-fabric/p2/blob/master/CHANGELOG.md
118
131
  rdoc_options:
119
132
  - "--title"