hamlit 0.5.3 → 0.6.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.
@@ -2,16 +2,11 @@ require 'hamlit'
2
2
  require 'unindent'
3
3
 
4
4
  module HamlitSpecHelper
5
- DEFAULT_OPTIONS = {
6
- ugly: true,
7
- }.freeze
8
-
9
5
  def parse_string(str)
10
6
  Hamlit::Parser.new.call(str)
11
7
  end
12
8
 
13
9
  def render_string(str, options = {})
14
- options = DEFAULT_OPTIONS.merge(options)
15
10
  eval Hamlit::Engine.new(options).call(str)
16
11
  end
17
12
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hamlit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.3
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Takashi Kokubun
@@ -311,7 +311,6 @@ files:
311
311
  - lib/hamlit/compilers/filter.rb
312
312
  - lib/hamlit/compilers/new_attribute.rb
313
313
  - lib/hamlit/compilers/old_attribute.rb
314
- - lib/hamlit/compilers/preserve.rb
315
314
  - lib/hamlit/compilers/runtime_attribute.rb
316
315
  - lib/hamlit/compilers/script.rb
317
316
  - lib/hamlit/compilers/strip.rb
@@ -320,7 +319,6 @@ files:
320
319
  - lib/hamlit/concerns/balanceable.rb
321
320
  - lib/hamlit/concerns/deprecation.rb
322
321
  - lib/hamlit/concerns/error.rb
323
- - lib/hamlit/concerns/escapable.rb
324
322
  - lib/hamlit/concerns/included.rb
325
323
  - lib/hamlit/concerns/indentable.rb
326
324
  - lib/hamlit/concerns/line_reader.rb
@@ -343,8 +341,7 @@ files:
343
341
  - lib/hamlit/filters/scss.rb
344
342
  - lib/hamlit/filters/tilt.rb
345
343
  - lib/hamlit/helpers.rb
346
- - lib/hamlit/html/pretty.rb
347
- - lib/hamlit/html/ugly.rb
344
+ - lib/hamlit/html.rb
348
345
  - lib/hamlit/parser.rb
349
346
  - lib/hamlit/parsers/attribute.rb
350
347
  - lib/hamlit/parsers/comment.rb
@@ -359,7 +356,6 @@ files:
359
356
  - lib/hamlit/template.rb
360
357
  - lib/hamlit/version.rb
361
358
  - spec/Rakefile
362
- - spec/hamlit/compilers/script_spec.rb
363
359
  - spec/hamlit/engine/comment_spec.rb
364
360
  - spec/hamlit/engine/doctype_spec.rb
365
361
  - spec/hamlit/engine/error_spec.rb
@@ -367,7 +363,6 @@ files:
367
363
  - spec/hamlit/engine/multiline_spec.rb
368
364
  - spec/hamlit/engine/new_attribute_spec.rb
369
365
  - spec/hamlit/engine/old_attributes_spec.rb
370
- - spec/hamlit/engine/preservation_spec.rb
371
366
  - spec/hamlit/engine/script_spec.rb
372
367
  - spec/hamlit/engine/silent_script_spec.rb
373
368
  - spec/hamlit/engine/tag_spec.rb
@@ -382,7 +377,7 @@ files:
382
377
  - spec/hamlit/filters/ruby_spec.rb
383
378
  - spec/hamlit/filters/sass_spec.rb
384
379
  - spec/hamlit/filters/scss_spec.rb
385
- - spec/hamlit/ugly_spec.rb
380
+ - spec/hamlit/haml_spec.rb
386
381
  - spec/rails/.gitignore
387
382
  - spec/rails/.rspec
388
383
  - spec/rails/Gemfile
@@ -473,7 +468,6 @@ specification_version: 4
473
468
  summary: High Performance Haml Implementation
474
469
  test_files:
475
470
  - spec/Rakefile
476
- - spec/hamlit/compilers/script_spec.rb
477
471
  - spec/hamlit/engine/comment_spec.rb
478
472
  - spec/hamlit/engine/doctype_spec.rb
479
473
  - spec/hamlit/engine/error_spec.rb
@@ -481,7 +475,6 @@ test_files:
481
475
  - spec/hamlit/engine/multiline_spec.rb
482
476
  - spec/hamlit/engine/new_attribute_spec.rb
483
477
  - spec/hamlit/engine/old_attributes_spec.rb
484
- - spec/hamlit/engine/preservation_spec.rb
485
478
  - spec/hamlit/engine/script_spec.rb
486
479
  - spec/hamlit/engine/silent_script_spec.rb
487
480
  - spec/hamlit/engine/tag_spec.rb
@@ -496,7 +489,7 @@ test_files:
496
489
  - spec/hamlit/filters/ruby_spec.rb
497
490
  - spec/hamlit/filters/sass_spec.rb
498
491
  - spec/hamlit/filters/scss_spec.rb
499
- - spec/hamlit/ugly_spec.rb
492
+ - spec/hamlit/haml_spec.rb
500
493
  - spec/rails/.gitignore
501
494
  - spec/rails/.rspec
502
495
  - spec/rails/Gemfile
@@ -1,10 +0,0 @@
1
- module Hamlit
2
- module Compilers
3
- module Preserve
4
- def on_haml_preserve(code)
5
- code = "Hamlit::Helpers.find_and_preserve(#{code})"
6
- [:dynamic, code]
7
- end
8
- end
9
- end
10
- end
@@ -1,17 +0,0 @@
1
- require 'hamlit/concerns/included'
2
-
3
- module Hamlit
4
- module Concerns
5
- module Escapable
6
- extend Included
7
-
8
- included do
9
- define_options escape_html: false
10
- end
11
-
12
- def escape_html(exp, force_escape = false)
13
- [:escape, force_escape || @options[:escape_html], exp]
14
- end
15
- end
16
- end
17
- end
@@ -1,49 +0,0 @@
1
- require 'hamlit/concerns/deprecation'
2
- require 'temple/html/pretty'
3
-
4
- # NOTE: This does not work and disabled by default.
5
- # Actually on_static is just a workaround. This should be totally rewritten.
6
- # Because pretty mode is not used on production and not so important,
7
- # it is not done for now.
8
- module Hamlit
9
- module HTML
10
- class Pretty < Temple::HTML::Pretty
11
- include Concerns::Deprecation
12
-
13
- def call(exp)
14
- result = super(exp)
15
- result << [:static, "\n"] if @added_newline
16
- result
17
- end
18
-
19
- def on_static(exp)
20
- if exp == "\n"
21
- @added_newline = true
22
- [:static, '']
23
- else
24
- [:static, exp]
25
- end
26
- end
27
-
28
- def on_html_tag(name, attrs, content = nil)
29
- if content.is_a?(Array) && content.first != :multi
30
- return parse_oneline_tag(name, attrs, content)
31
- end
32
-
33
- super
34
- end
35
-
36
- private
37
-
38
- def parse_oneline_tag(name, attrs, content)
39
- name = name.to_s
40
- closed = !content || (empty_exp?(content) && (@format == :xml || options[:autoclose].include?(name)))
41
- result = [:multi, [:static, "<#{name}"], compile(attrs)]
42
- result << [:static, (closed && @format != :html ? ' /' : '') + '>']
43
- result << compile(content) if content
44
- result << [:static, "</#{name}>"] if !closed
45
- result
46
- end
47
- end
48
- end
49
- end
@@ -1,10 +0,0 @@
1
- require 'hamlit/concerns/deprecation'
2
- require 'temple/html/fast'
3
-
4
- module Hamlit
5
- module HTML
6
- class Ugly < Temple::HTML::Fast
7
- include Concerns::Deprecation
8
- end
9
- end
10
- end
@@ -1,46 +0,0 @@
1
- describe Hamlit::Compiler do
2
- describe 'script' do
3
- let(:options) do
4
- { force_escape: false, disable_escape: false }
5
- end
6
-
7
- it 'compiles hamlit script ast into assigning' do
8
- assert_compile(
9
- [:haml,
10
- :script,
11
- 'link_to user_path do',
12
- options,
13
- [:static, 'user']],
14
- [:multi,
15
- [:code, "_hamlit_compiler0 = link_to user_path do"],
16
- [:static, "user"],
17
- [:escape, false, [:dynamic, "(_hamlit_compiler0).to_s"]]],
18
- )
19
- end
20
-
21
- it 'compiles multiple hamlit scripts' do
22
- assert_compile(
23
- [:multi,
24
- [:haml,
25
- :script,
26
- 'link_to user_path do',
27
- options,
28
- [:static, 'user']],
29
- [:haml,
30
- :script,
31
- 'link_to repo_path do',
32
- options,
33
- [:static, 'repo']]],
34
- [:multi,
35
- [:multi,
36
- [:code, "_hamlit_compiler0 = link_to user_path do"],
37
- [:static, "user"],
38
- [:escape, false, [:dynamic, "(_hamlit_compiler0).to_s"]]],
39
- [:multi,
40
- [:code, "_hamlit_compiler1 = link_to repo_path do"],
41
- [:static, "repo"],
42
- [:escape, false, [:dynamic, "(_hamlit_compiler1).to_s"]]]],
43
- )
44
- end
45
- end
46
- end
@@ -1,11 +0,0 @@
1
- describe Hamlit::Parser do
2
- describe 'preservation' do
3
- it 'renders whitespace preservation operator' do
4
- assert_render(<<-'HAML', <<-HTML)
5
- ~ "<code>hello\nworld</code>"
6
- HAML
7
- <code>hello&#x000A;world</code>
8
- HTML
9
- end
10
- end
11
- end