faml 0.2.9 → 0.2.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +3 -0
- data/README.md +8 -0
- data/benchmark/compiling.rb +2 -0
- data/benchmark/rendering.rb +5 -0
- data/benchmark/slim.rb +3 -0
- data/faml.gemspec +1 -0
- data/lib/faml/parser.rb +2 -2
- data/lib/faml/ruby_multiline.rb +1 -1
- data/lib/faml/script_parser.rb +9 -9
- data/lib/faml/version.rb +1 -1
- data/spec/compiler_newline_spec.rb +9 -0
- metadata +17 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 05912ba9442dfe72d17b8f1e9aacbf1484b036e7
|
4
|
+
data.tar.gz: d84fdc9481afa2e31fefb7b180a45664197706a2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 71e2974457f43aca89266a3dde091a0306db1f1d8c5bee5ed9a69d3efc0dde87ef5386023acf19f6864860383d01158b88aeda3a6607719c7ccababc1277fdf3
|
7
|
+
data.tar.gz: a0b4b25fccb960ec88a9733fe34610e27a7d984c53fc79c3690b55a2cb508b0b7f705963877be2a79faf39f09ba3c7e48bc75167c9122b138352506dcdfdb501
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -24,8 +24,16 @@ Or install it yourself as:
|
|
24
24
|
|
25
25
|
## Usage
|
26
26
|
|
27
|
+
### Rails, sinatra
|
27
28
|
Just replace your `gem 'haml'` with `gem 'faml'` .
|
28
29
|
|
30
|
+
### middleman
|
31
|
+
Since middleman has its own renderers, there's no easy way to use faml with middleman currently.
|
32
|
+
|
33
|
+
### Others
|
34
|
+
faml provide a [tilt](https://github.com/rtomayko/tilt) interface.
|
35
|
+
If your framework uses tilt, you can use faml by replacing `gem 'haml'` with `gem 'faml'` .
|
36
|
+
|
29
37
|
## Incompatibilities
|
30
38
|
There are several incompatibilities.
|
31
39
|
|
data/benchmark/compiling.rb
CHANGED
@@ -2,6 +2,7 @@
|
|
2
2
|
require 'benchmark/ips'
|
3
3
|
require 'haml'
|
4
4
|
require 'faml'
|
5
|
+
require 'hamlit'
|
5
6
|
require 'slim'
|
6
7
|
require 'escape_utils/html/haml'
|
7
8
|
|
@@ -16,6 +17,7 @@ slim_code = ARGV[1] ? File.read(ARGV[1]) : nil
|
|
16
17
|
Benchmark.ips do |x|
|
17
18
|
x.report('Haml') { Haml::Engine.new(haml_code, ugly: true, escape_html: true) }
|
18
19
|
x.report('Faml') { Faml::Engine.new.call(haml_code) }
|
20
|
+
x.report('Hamlit') { Hamlit::Engine.new(escape_html: true).call(haml_code) }
|
19
21
|
if slim_code
|
20
22
|
x.report('Slim') { Slim::Engine.new.call(slim_code) }
|
21
23
|
end
|
data/benchmark/rendering.rb
CHANGED
@@ -2,6 +2,7 @@
|
|
2
2
|
require 'benchmark/ips'
|
3
3
|
require 'haml'
|
4
4
|
require 'faml'
|
5
|
+
require 'hamlit'
|
5
6
|
require 'slim'
|
6
7
|
require 'escape_utils/html/haml'
|
7
8
|
|
@@ -20,6 +21,8 @@ Benchmark.ips do |x|
|
|
20
21
|
obj.instance_eval %{
|
21
22
|
def faml_array; #{Faml::Engine.new.call(haml_code)}; end
|
22
23
|
def faml_string; #{Faml::Engine.new(generator: Temple::Generators::RailsOutputBuffer).call(haml_code)}; end
|
24
|
+
def hamlit_array; #{Hamlit::Engine.new(escape_html: true).call(haml_code)}; end
|
25
|
+
def hamlit_string; #{Hamlit::Engine.new(escape_html: true, generator: Temple::Generators::RailsOutputBuffer).call(haml_code)}; end
|
23
26
|
}
|
24
27
|
if slim_code
|
25
28
|
obj.instance_eval %{
|
@@ -31,6 +34,8 @@ Benchmark.ips do |x|
|
|
31
34
|
x.report('Haml') { obj.haml }
|
32
35
|
x.report('Faml (Array)') { obj.faml_array }
|
33
36
|
x.report('Faml (String)') { obj.faml_string }
|
37
|
+
x.report('Hamlit (Array)') { obj.hamlit_array }
|
38
|
+
x.report('Hamlit (String)') { obj.hamlit_string }
|
34
39
|
if slim_code
|
35
40
|
x.report('Slim (Array)') { obj.slim_array }
|
36
41
|
x.report('Slim (String)') { obj.slim_string }
|
data/benchmark/slim.rb
CHANGED
@@ -2,6 +2,7 @@
|
|
2
2
|
require 'benchmark/ips'
|
3
3
|
require 'haml'
|
4
4
|
require 'faml'
|
5
|
+
require 'hamlit'
|
5
6
|
require 'slim'
|
6
7
|
require 'escape_utils/html/haml'
|
7
8
|
|
@@ -14,12 +15,14 @@ context = Context.new
|
|
14
15
|
Haml::Engine.new(haml_code, ugly: true, escape_html: true).def_method(context, :haml)
|
15
16
|
context.instance_eval %{
|
16
17
|
def faml; #{Faml::Engine.new(generator: Temple::Generators::RailsOutputBuffer).call(haml_code)}; end
|
18
|
+
def hamlit; #{Hamlit::Engine.new(escape_html: true, generator: Temple::Generators::RailsOutputBuffer).call(haml_code)}; end
|
17
19
|
def slim; #{Slim::Engine.new(generator: Temple::Generators::RailsOutputBuffer).call(slim_code)}; end
|
18
20
|
}
|
19
21
|
|
20
22
|
Benchmark.ips do |x|
|
21
23
|
x.report('Haml') { context.haml }
|
22
24
|
x.report('Faml') { context.faml }
|
25
|
+
x.report('Hamlit') { context.hamlit }
|
23
26
|
x.report('Slim') { context.slim }
|
24
27
|
x.compare!
|
25
28
|
end
|
data/faml.gemspec
CHANGED
@@ -29,6 +29,7 @@ Gem::Specification.new do |spec|
|
|
29
29
|
spec.add_development_dependency "coffee-script"
|
30
30
|
spec.add_development_dependency "coveralls"
|
31
31
|
spec.add_development_dependency "haml" # for benchmark
|
32
|
+
spec.add_development_dependency "hamlit" # for benchmark
|
32
33
|
spec.add_development_dependency "rake"
|
33
34
|
spec.add_development_dependency "rake-compiler"
|
34
35
|
spec.add_development_dependency "redcarpet"
|
data/lib/faml/parser.rb
CHANGED
@@ -151,8 +151,8 @@ module Faml
|
|
151
151
|
return
|
152
152
|
end
|
153
153
|
node = create_node(Ast::SilentScript)
|
154
|
-
|
155
|
-
node.script
|
154
|
+
script = text[/\A- *(.*)\z/, 1]
|
155
|
+
node.script = [script, *RubyMultiline.read(@line_parser, script)].join("\n")
|
156
156
|
@ast << node
|
157
157
|
end
|
158
158
|
|
data/lib/faml/ruby_multiline.rb
CHANGED
data/lib/faml/script_parser.rb
CHANGED
@@ -28,11 +28,11 @@ module Faml
|
|
28
28
|
create_node(Ast::Text) { |t| t.text = text[2 .. -1].strip }
|
29
29
|
else
|
30
30
|
node = create_node(Ast::Script)
|
31
|
-
|
32
|
-
if
|
31
|
+
script = text[1 .. -1].lstrip
|
32
|
+
if script.empty?
|
33
33
|
syntax_error!('No Ruby code to evaluate')
|
34
34
|
end
|
35
|
-
node.script
|
35
|
+
node.script = [script, *RubyMultiline.read(@line_parser, script)].join("\n")
|
36
36
|
node
|
37
37
|
end
|
38
38
|
end
|
@@ -43,11 +43,11 @@ module Faml
|
|
43
43
|
create_node(Ast::Text) { |t| t.text = text[3 .. -1].lstrip }
|
44
44
|
when text[1] == '=' || text[1] == '~'
|
45
45
|
node = create_node(Ast::Script)
|
46
|
-
|
47
|
-
if
|
46
|
+
script = text[2 .. -1].lstrip
|
47
|
+
if script.empty?
|
48
48
|
syntax_error!('No Ruby code to evaluate')
|
49
49
|
end
|
50
|
-
node.script
|
50
|
+
node.script = [script, *RubyMultiline.read(@line_parser, script)].join("\n")
|
51
51
|
node.preserve = text[1] == '~'
|
52
52
|
node
|
53
53
|
else
|
@@ -65,11 +65,11 @@ module Faml
|
|
65
65
|
when text[1] == '=' || text[1] == '~'
|
66
66
|
node = create_node(Ast::Script)
|
67
67
|
node.escape_html = false
|
68
|
-
|
69
|
-
if
|
68
|
+
script = text[2 .. -1].lstrip
|
69
|
+
if script.empty?
|
70
70
|
syntax_error!('No Ruby code to evaluate')
|
71
71
|
end
|
72
|
-
node.script
|
72
|
+
node.script = [script, *RubyMultiline.read(@line_parser, script)].join("\n")
|
73
73
|
node.preserve = text[1] == '~'
|
74
74
|
node
|
75
75
|
else
|
data/lib/faml/version.rb
CHANGED
@@ -195,6 +195,15 @@ HAML
|
|
195
195
|
'bar ' + |
|
196
196
|
__LINE__.to_s |
|
197
197
|
= __LINE__
|
198
|
+
HAML
|
199
|
+
end
|
200
|
+
|
201
|
+
it 'keeps newlines in Ruby multiline' do
|
202
|
+
expect(render_string(<<HAML)).to eq("1 2 3\n<span>4</span>\n")
|
203
|
+
= [__LINE__,
|
204
|
+
__LINE__,
|
205
|
+
__LINE__].join(' ')
|
206
|
+
%span= __LINE__
|
198
207
|
HAML
|
199
208
|
end
|
200
209
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: faml
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kohei Suzuki
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-04-
|
11
|
+
date: 2015-04-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: escape_utils
|
@@ -150,6 +150,20 @@ dependencies:
|
|
150
150
|
- - ">="
|
151
151
|
- !ruby/object:Gem::Version
|
152
152
|
version: '0'
|
153
|
+
- !ruby/object:Gem::Dependency
|
154
|
+
name: hamlit
|
155
|
+
requirement: !ruby/object:Gem::Requirement
|
156
|
+
requirements:
|
157
|
+
- - ">="
|
158
|
+
- !ruby/object:Gem::Version
|
159
|
+
version: '0'
|
160
|
+
type: :development
|
161
|
+
prerelease: false
|
162
|
+
version_requirements: !ruby/object:Gem::Requirement
|
163
|
+
requirements:
|
164
|
+
- - ">="
|
165
|
+
- !ruby/object:Gem::Version
|
166
|
+
version: '0'
|
153
167
|
- !ruby/object:Gem::Dependency
|
154
168
|
name: rake
|
155
169
|
requirement: !ruby/object:Gem::Requirement
|
@@ -433,7 +447,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
433
447
|
version: '0'
|
434
448
|
requirements: []
|
435
449
|
rubyforge_project:
|
436
|
-
rubygems_version: 2.
|
450
|
+
rubygems_version: 2.2.2
|
437
451
|
signing_key:
|
438
452
|
specification_version: 4
|
439
453
|
summary: Faster implementation of Haml template language.
|