hamlit-block 0.3.1 → 0.4.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/README.md +3 -1
- data/bin/console +2 -9
- data/hamlit-block.gemspec +1 -1
- data/lib/hamlit/block.rb +1 -15
- data/lib/hamlit/block/compiler.rb +20 -0
- data/lib/hamlit/block/engine.rb +33 -0
- data/lib/hamlit/block/{script_compiler_extension.rb → script_compiler.rb} +1 -3
- data/lib/hamlit/block/{silent_script_compiler_extension.rb → silent_script_compiler.rb} +4 -2
- data/lib/hamlit/block/version.rb +10 -1
- metadata +12 -10
- data/lib/hamlit/block/compiler_extension.rb +0 -11
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 1b62b48437a95c5a66b0a728ddc1bcd37aeaec64
|
|
4
|
+
data.tar.gz: 46b1e5a1cf26f7730bc9343e3f601e17ab029b5e
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: fe5f0360b02aa69724a86bcc178dfca4d4eaab15bcc67803401e18f017a12cb55dd1af8d0f716ebb4a8d48f813fa19a10145007c6d02a2a9d3a97fb9a1c97a46
|
|
7
|
+
data.tar.gz: 28a7067b9bad5707fee6b06c8cf6cf19176857c354bb3bca05525fc37e280154553e75d1bcad8237ebf2e7f8c4928aaa4d5786ec8311064d4ee012f8170dfa1c
|
data/README.md
CHANGED
|
@@ -16,7 +16,9 @@ And then execute:
|
|
|
16
16
|
|
|
17
17
|
## Usage
|
|
18
18
|
|
|
19
|
-
Basically the same as Hamlit. `require 'hamlit/block'` may be necessary. Contents inside script block is not rendered but available via `yield`.
|
|
19
|
+
Basically the same as Hamlit. `require 'hamlit/block'` may be necessary. Contents inside script block is not rendered but available via `yield`.
|
|
20
|
+
|
|
21
|
+
See [spec](spec/hamlit/block_spec.rb) for detail.
|
|
20
22
|
|
|
21
23
|
## License
|
|
22
24
|
|
data/bin/console
CHANGED
|
@@ -3,12 +3,5 @@
|
|
|
3
3
|
require "bundler/setup"
|
|
4
4
|
require "hamlit/block"
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
# (If you use this, don't forget to add pry to your Gemfile!)
|
|
10
|
-
# require "pry"
|
|
11
|
-
# Pry.start
|
|
12
|
-
|
|
13
|
-
require "irb"
|
|
14
|
-
IRB.start
|
|
6
|
+
require "pry"
|
|
7
|
+
Pry.start
|
data/hamlit-block.gemspec
CHANGED
|
@@ -19,7 +19,7 @@ Gem::Specification.new do |spec|
|
|
|
19
19
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
|
20
20
|
spec.require_paths = ["lib"]
|
|
21
21
|
|
|
22
|
-
spec.add_dependency "hamlit", "
|
|
22
|
+
spec.add_dependency "hamlit", ">= 2"
|
|
23
23
|
|
|
24
24
|
spec.add_development_dependency "bundler", "~> 1.11"
|
|
25
25
|
spec.add_development_dependency "pry"
|
data/lib/hamlit/block.rb
CHANGED
|
@@ -1,17 +1,3 @@
|
|
|
1
1
|
require "hamlit"
|
|
2
|
-
require "hamlit/block/
|
|
3
|
-
require "hamlit/block/script_compiler_extension"
|
|
4
|
-
require "hamlit/block/silent_script_compiler_extension"
|
|
2
|
+
require "hamlit/block/engine"
|
|
5
3
|
require "hamlit/block/version"
|
|
6
|
-
|
|
7
|
-
module Hamlit
|
|
8
|
-
class Compiler
|
|
9
|
-
prepend Block::CompilerExtension
|
|
10
|
-
|
|
11
|
-
ScriptCompiler.send(:prepend, Block::ScriptCompilerExtension)
|
|
12
|
-
SilentScriptCompiler.send(:prepend, Block::SilentScriptCompilerExtension)
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
# Maybe hamlit-block's users expect this. This is Haml's default.
|
|
16
|
-
Engine.options[:escape_html] = false
|
|
17
|
-
end
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
require 'hamlit/block/script_compiler'
|
|
2
|
+
require 'hamlit/block/silent_script_compiler'
|
|
3
|
+
|
|
4
|
+
module Hamlit
|
|
5
|
+
module Block
|
|
6
|
+
class Compiler < ::Hamlit::Compiler
|
|
7
|
+
def initialize(options = {})
|
|
8
|
+
super
|
|
9
|
+
|
|
10
|
+
# Re-generate identity for Hamlit::Block and share it
|
|
11
|
+
identity = Identity.new
|
|
12
|
+
@tag_compiler = ::Hamlit::Compiler::TagCompiler.new(identity, options)
|
|
13
|
+
|
|
14
|
+
# Replace internal compilers with Hamlit::Block's ones.
|
|
15
|
+
@script_compiler = ::Hamlit::Block::ScriptCompiler.new(identity)
|
|
16
|
+
@silent_script_compiler = ::Hamlit::Block::SilentScriptCompiler.new(identity)
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
require 'hamlit/engine'
|
|
2
|
+
require 'hamlit/block/compiler'
|
|
3
|
+
|
|
4
|
+
module Hamlit
|
|
5
|
+
module Block
|
|
6
|
+
class Engine < Temple::Engine
|
|
7
|
+
define_options(
|
|
8
|
+
:buffer_class,
|
|
9
|
+
generator: Temple::Generators::ArrayBuffer,
|
|
10
|
+
format: :html,
|
|
11
|
+
attr_quote: "'",
|
|
12
|
+
escape_html: false,
|
|
13
|
+
escape_attrs: true,
|
|
14
|
+
autoclose: %w(area base basefont br col command embed frame
|
|
15
|
+
hr img input isindex keygen link menuitem meta
|
|
16
|
+
param source track wbr),
|
|
17
|
+
filename: "",
|
|
18
|
+
)
|
|
19
|
+
|
|
20
|
+
use Hamlit::Parser
|
|
21
|
+
use Hamlit::Block::Compiler
|
|
22
|
+
use Hamlit::HTML
|
|
23
|
+
use Hamlit::StringSplitter
|
|
24
|
+
use Hamlit::StaticAnalyzer
|
|
25
|
+
use Hamlit::Escapable
|
|
26
|
+
use Hamlit::ForceEscapable
|
|
27
|
+
filter :ControlFlow
|
|
28
|
+
filter :MultiFlattener
|
|
29
|
+
filter :StaticMerger
|
|
30
|
+
use :Generator, -> { options[:generator] }
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
module Hamlit
|
|
2
2
|
module Block
|
|
3
3
|
# Suppress block's internal rendering result and pass it to [:capture, ...].
|
|
4
|
-
|
|
5
|
-
attr_reader :identity
|
|
6
|
-
|
|
4
|
+
class ScriptCompiler < ::Hamlit::Compiler::ScriptCompiler
|
|
7
5
|
def compile_script_assign(var, node, &block)
|
|
8
6
|
if node.children.empty?
|
|
9
7
|
super
|
|
@@ -2,8 +2,10 @@ module Hamlit
|
|
|
2
2
|
module Block
|
|
3
3
|
# Suppress block's internal rendering result and pass it to [:capture, ...]
|
|
4
4
|
# if the silent script is `do .. end` block
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
class SilentScriptCompiler < ::Hamlit::Compiler::SilentScriptCompiler
|
|
6
|
+
def initialize(identity)
|
|
7
|
+
@identity = identity
|
|
8
|
+
end
|
|
7
9
|
|
|
8
10
|
BLOCK_REGEX = /do(\s*\|\s*[^\|]*\s*\|)?\s*\z/
|
|
9
11
|
|
data/lib/hamlit/block/version.rb
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
module Hamlit
|
|
2
2
|
module Block
|
|
3
|
-
VERSION = "0.
|
|
3
|
+
VERSION = "0.4.0"
|
|
4
|
+
|
|
5
|
+
begin
|
|
6
|
+
require 'cell/hamlit/version'
|
|
7
|
+
rescue LoadError
|
|
8
|
+
else
|
|
9
|
+
if Gem::Version.new(Cell::Hamlit::VERSION) <= Gem::Version.new('0.2')
|
|
10
|
+
raise NotImplementedError.new('hamlit-block does not support cells-hamlit <= 0.2. See https://github.com/trailblazer/cells-hamlit/issues/6')
|
|
11
|
+
end
|
|
12
|
+
end
|
|
4
13
|
end
|
|
5
14
|
end
|
metadata
CHANGED
|
@@ -1,29 +1,29 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: hamlit-block
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.4.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Takashi Kokubun
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2017-02-02 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: hamlit
|
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
|
16
16
|
requirements:
|
|
17
|
-
- - "
|
|
17
|
+
- - ">="
|
|
18
18
|
- !ruby/object:Gem::Version
|
|
19
|
-
version: '2
|
|
19
|
+
version: '2'
|
|
20
20
|
type: :runtime
|
|
21
21
|
prerelease: false
|
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
|
23
23
|
requirements:
|
|
24
|
-
- - "
|
|
24
|
+
- - ">="
|
|
25
25
|
- !ruby/object:Gem::Version
|
|
26
|
-
version: '2
|
|
26
|
+
version: '2'
|
|
27
27
|
- !ruby/object:Gem::Dependency
|
|
28
28
|
name: bundler
|
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -112,9 +112,10 @@ files:
|
|
|
112
112
|
- bin/setup
|
|
113
113
|
- hamlit-block.gemspec
|
|
114
114
|
- lib/hamlit/block.rb
|
|
115
|
-
- lib/hamlit/block/
|
|
116
|
-
- lib/hamlit/block/
|
|
117
|
-
- lib/hamlit/block/
|
|
115
|
+
- lib/hamlit/block/compiler.rb
|
|
116
|
+
- lib/hamlit/block/engine.rb
|
|
117
|
+
- lib/hamlit/block/script_compiler.rb
|
|
118
|
+
- lib/hamlit/block/silent_script_compiler.rb
|
|
118
119
|
- lib/hamlit/block/version.rb
|
|
119
120
|
homepage: https://github.com/hamlit/hamlit-block
|
|
120
121
|
licenses:
|
|
@@ -136,8 +137,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
136
137
|
version: '0'
|
|
137
138
|
requirements: []
|
|
138
139
|
rubyforge_project:
|
|
139
|
-
rubygems_version: 2.
|
|
140
|
+
rubygems_version: 2.6.8
|
|
140
141
|
signing_key:
|
|
141
142
|
specification_version: 4
|
|
142
143
|
summary: Hamlit extension to support capturing via yield
|
|
143
144
|
test_files: []
|
|
145
|
+
has_rdoc:
|