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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: da0d5a40e368fd95bce13511a6c083c338a79698
4
- data.tar.gz: 5835483174f686095295d5a93dcd00decd5c1e49
3
+ metadata.gz: 05912ba9442dfe72d17b8f1e9aacbf1484b036e7
4
+ data.tar.gz: d84fdc9481afa2e31fefb7b180a45664197706a2
5
5
  SHA512:
6
- metadata.gz: dc1faad685fd051a3a2fcbd63f4dc6059b300d6e66a57aad98e77662f13da0bcc4205bd261f2d90bfa9bb5f9abf23ba504be2c988e168ef9f282a90ec7dd6c09
7
- data.tar.gz: 1cf54d88358b06fdd8f9b2c78a2415820fc83a0f806ab16bd4a98b076b03fcc8bbf93e069d0f3cb5fc1337c8b5a682acbeca952c35b33df612200386a2ff0b68
6
+ metadata.gz: 71e2974457f43aca89266a3dde091a0306db1f1d8c5bee5ed9a69d3efc0dde87ef5386023acf19f6864860383d01158b88aeda3a6607719c7ccababc1277fdf3
7
+ data.tar.gz: a0b4b25fccb960ec88a9733fe34610e27a7d984c53fc79c3690b55a2cb508b0b7f705963877be2a79faf39f09ba3c7e48bc75167c9122b138352506dcdfdb501
data/CHANGELOG.md CHANGED
@@ -1,3 +1,6 @@
1
+ ## 0.2.10 (2015-04-06)
2
+ - Keep code newlines within Ruby multiline
3
+
1
4
  ## 0.2.9 (2015-04-04)
2
5
  - Keep code newlines with multiline
3
6
  - https://github.com/eagletmt/faml/issues/18
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
 
@@ -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
@@ -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
- node.script = text[/\A- *(.*)\z/, 1]
155
- node.script += RubyMultiline.read(@line_parser, 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
 
@@ -6,7 +6,7 @@ module Faml
6
6
  current_text = line_parser.next_line
7
7
  buf << current_text
8
8
  end
9
- buf.join("\n")
9
+ buf
10
10
  end
11
11
 
12
12
  # `text' is a Ruby multiline block if it:
@@ -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
- node.script = text[1 .. -1].lstrip
32
- if node.script.empty?
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 += RubyMultiline.read(@line_parser, 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
- node.script = text[2 .. -1].lstrip
47
- if node.script.empty?
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 += RubyMultiline.read(@line_parser, 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
- node.script = text[2 .. -1].lstrip
69
- if node.script.empty?
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 += RubyMultiline.read(@line_parser, 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
@@ -1,3 +1,3 @@
1
1
  module Faml
2
- VERSION = "0.2.9"
2
+ VERSION = "0.2.10"
3
3
  end
@@ -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.9
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-04 00:00:00.000000000 Z
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.4.5
450
+ rubygems_version: 2.2.2
437
451
  signing_key:
438
452
  specification_version: 4
439
453
  summary: Faster implementation of Haml template language.