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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/README.md +2 -11
- data/Rakefile +3 -10
- data/benchmarks/benchmark.rb +1 -2
- data/lib/hamlit/compiler.rb +0 -2
- data/lib/hamlit/compilers/attributes.rb +1 -4
- data/lib/hamlit/compilers/script.rb +1 -10
- data/lib/hamlit/engine.rb +5 -15
- data/lib/hamlit/html.rb +10 -0
- data/lib/hamlit/parser.rb +2 -4
- data/lib/hamlit/parsers/script.rb +3 -17
- data/lib/hamlit/railtie.rb +0 -2
- data/lib/hamlit/version.rb +1 -1
- data/spec/Rakefile +15 -14
- data/spec/hamlit/engine/script_spec.rb +12 -3
- data/spec/hamlit/engine/silent_script_spec.rb +1 -1
- data/spec/hamlit/engine_spec.rb +0 -1
- data/spec/hamlit/{ugly_spec.rb → haml_spec.rb} +108 -102
- data/spec/spec_helper.rb +0 -5
- metadata +4 -11
- data/lib/hamlit/compilers/preserve.rb +0 -10
- data/lib/hamlit/concerns/escapable.rb +0 -17
- data/lib/hamlit/html/pretty.rb +0 -49
- data/lib/hamlit/html/ugly.rb +0 -10
- data/spec/hamlit/compilers/script_spec.rb +0 -46
- data/spec/hamlit/engine/preservation_spec.rb +0 -11
data/spec/spec_helper.rb
CHANGED
@@ -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.
|
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
|
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/
|
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/
|
492
|
+
- spec/hamlit/haml_spec.rb
|
500
493
|
- spec/rails/.gitignore
|
501
494
|
- spec/rails/.rspec
|
502
495
|
- spec/rails/Gemfile
|
@@ -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
|
data/lib/hamlit/html/pretty.rb
DELETED
@@ -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
|
data/lib/hamlit/html/ugly.rb
DELETED
@@ -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
|