papercraft 3.0.2 → 3.2.0
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 +8 -0
- data/lib/papercraft/proc.rb +29 -0
- data/lib/papercraft/version.rb +1 -1
- data/lib/tilt/papercraft.rb +51 -0
- metadata +17 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 2fbc68541f31501137d57fba620c650218b5c1e16940f40c8e87707f117ac9c1
|
|
4
|
+
data.tar.gz: 8edf1481f1fee51f0fd347eeb67d907fb40712716e5b6c1dac403973e7d453ef
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 91377f2fa5778dc5d800f3ba7c130bf67feb0621d718cee4abed52d2d5e8d19dbde93069a84fbd289c10477079a37cb80318db39b8f9ae670818aee3e52cf678
|
|
7
|
+
data.tar.gz: 3ef5ebda7e979f25f719553b44ad7ad8bbc0d8e00dcbc50b3381f82b273961863b269def6d9f65251a7f46a3d820893aabd2a00223c6a8b6ff73007d454bf22f
|
data/CHANGELOG.md
CHANGED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative '../papercraft'
|
|
4
|
+
|
|
5
|
+
module Papercraft
|
|
6
|
+
module ProcAPI
|
|
7
|
+
def ast
|
|
8
|
+
Papercraft.ast(self)
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def compiled_code
|
|
12
|
+
Papercraft.compiled_code(self)
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def to_html(*, **, &)
|
|
16
|
+
Papercraft.html(self, *, **, &)
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def to_xml(*, **, &)
|
|
20
|
+
Papercraft.xml(self, *, **, &)
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def apply(*, **, &)
|
|
24
|
+
Papercraft.apply(self, *, **, &)
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
::Proc.prepend(Papercraft::ProcAPI)
|
data/lib/papercraft/version.rb
CHANGED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'papercraft'
|
|
4
|
+
require 'tilt'
|
|
5
|
+
require 'digest/sha1'
|
|
6
|
+
|
|
7
|
+
# Tilt.
|
|
8
|
+
module Tilt
|
|
9
|
+
# Papercraft templating engine for Tilt
|
|
10
|
+
class PapercraftTemplate < Template
|
|
11
|
+
module SiropExtension
|
|
12
|
+
# We override the Sirop get source in order to have access to the template
|
|
13
|
+
# source code when the template is compiled.
|
|
14
|
+
def get_source(fn)
|
|
15
|
+
return Tilt::PapercraftTemplate.file_load(fn) if fn.match(/@tilt\-/)
|
|
16
|
+
|
|
17
|
+
super
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
::Sirop.singleton_class.prepend(SiropExtension)
|
|
21
|
+
|
|
22
|
+
# "File system" for storing template source code
|
|
23
|
+
@@file_store = {}
|
|
24
|
+
def self.file_save(fn, data) = @@file_store[fn] = data
|
|
25
|
+
def self.file_load(fn) = @@file_store[fn]
|
|
26
|
+
|
|
27
|
+
metadata[:mime_type] = 'text/html'
|
|
28
|
+
|
|
29
|
+
protected
|
|
30
|
+
|
|
31
|
+
def prepare
|
|
32
|
+
src = <<~RUBY
|
|
33
|
+
# frozen_string_literal: true
|
|
34
|
+
-> (scope:, locals:, block:) {
|
|
35
|
+
#{data}
|
|
36
|
+
}
|
|
37
|
+
RUBY
|
|
38
|
+
fn = "@tilt-#{Digest::SHA1.hexdigest(src)}"
|
|
39
|
+
PapercraftTemplate.file_save(fn, src)
|
|
40
|
+
@template = eval(src, binding, fn)
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def evaluate(scope, locals, &block)
|
|
44
|
+
Papercraft.html(
|
|
45
|
+
@template, scope: scope, locals: locals, block: block
|
|
46
|
+
)
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
register(PapercraftTemplate, 'papercraft')
|
|
51
|
+
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: papercraft
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 3.0
|
|
4
|
+
version: 3.2.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Sharon Rosner
|
|
@@ -121,6 +121,20 @@ dependencies:
|
|
|
121
121
|
- - "~>"
|
|
122
122
|
- !ruby/object:Gem::Version
|
|
123
123
|
version: 1.15.2
|
|
124
|
+
- !ruby/object:Gem::Dependency
|
|
125
|
+
name: tilt
|
|
126
|
+
requirement: !ruby/object:Gem::Requirement
|
|
127
|
+
requirements:
|
|
128
|
+
- - "~>"
|
|
129
|
+
- !ruby/object:Gem::Version
|
|
130
|
+
version: 2.6.1
|
|
131
|
+
type: :development
|
|
132
|
+
prerelease: false
|
|
133
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
134
|
+
requirements:
|
|
135
|
+
- - "~>"
|
|
136
|
+
- !ruby/object:Gem::Version
|
|
137
|
+
version: 2.6.1
|
|
124
138
|
email: sharon@noteflakes.com
|
|
125
139
|
executables: []
|
|
126
140
|
extensions: []
|
|
@@ -134,9 +148,11 @@ files:
|
|
|
134
148
|
- lib/papercraft/compiler.rb
|
|
135
149
|
- lib/papercraft/compiler/nodes.rb
|
|
136
150
|
- lib/papercraft/compiler/tag_translator.rb
|
|
151
|
+
- lib/papercraft/proc.rb
|
|
137
152
|
- lib/papercraft/proc_ext.rb
|
|
138
153
|
- lib/papercraft/template.rb
|
|
139
154
|
- lib/papercraft/version.rb
|
|
155
|
+
- lib/tilt/papercraft.rb
|
|
140
156
|
- papercraft.png
|
|
141
157
|
homepage: http://github.com/digital-fabric/papercraft
|
|
142
158
|
licenses:
|