hamlit 2.6.1 → 2.6.2
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 +8 -0
- data/lib/hamlit.rb +1 -0
- data/lib/hamlit/attribute_builder.rb +1 -0
- data/lib/hamlit/attribute_compiler.rb +4 -3
- data/lib/hamlit/attribute_parser.rb +6 -5
- data/lib/hamlit/cli.rb +1 -0
- data/lib/hamlit/compiler.rb +1 -0
- data/lib/hamlit/compiler/children_compiler.rb +2 -1
- data/lib/hamlit/compiler/doctype_compiler.rb +1 -0
- data/lib/hamlit/compiler/script_compiler.rb +3 -2
- data/lib/hamlit/compiler/silent_script_compiler.rb +1 -0
- data/lib/hamlit/compiler/tag_compiler.rb +2 -1
- data/lib/hamlit/engine.rb +1 -0
- data/lib/hamlit/error.rb +1 -0
- data/lib/hamlit/escapable.rb +1 -0
- data/lib/hamlit/filters.rb +3 -0
- data/lib/hamlit/filters/base.rb +1 -0
- data/lib/hamlit/filters/cdata.rb +20 -0
- data/lib/hamlit/filters/coffee.rb +3 -2
- data/lib/hamlit/filters/css.rb +7 -6
- data/lib/hamlit/filters/erb.rb +1 -0
- data/lib/hamlit/filters/escaped.rb +1 -0
- data/lib/hamlit/filters/javascript.rb +7 -6
- data/lib/hamlit/filters/less.rb +3 -2
- data/lib/hamlit/filters/plain.rb +1 -0
- data/lib/hamlit/filters/preserve.rb +1 -0
- data/lib/hamlit/filters/ruby.rb +1 -0
- data/lib/hamlit/filters/sass.rb +3 -2
- data/lib/hamlit/filters/scss.rb +3 -2
- data/lib/hamlit/filters/text_base.rb +1 -0
- data/lib/hamlit/filters/tilt_base.rb +2 -1
- data/lib/hamlit/force_escapable.rb +1 -0
- data/lib/hamlit/helpers.rb +1 -0
- data/lib/hamlit/html.rb +1 -0
- data/lib/hamlit/identity.rb +1 -0
- data/lib/hamlit/object_ref.rb +1 -0
- data/lib/hamlit/parser.rb +1 -0
- data/lib/hamlit/rails_helpers.rb +1 -0
- data/lib/hamlit/rails_template.rb +1 -0
- data/lib/hamlit/railtie.rb +1 -0
- data/lib/hamlit/ruby_expression.rb +1 -0
- data/lib/hamlit/static_analyzer.rb +1 -0
- data/lib/hamlit/template.rb +1 -0
- data/lib/hamlit/utils.rb +1 -0
- data/lib/hamlit/version.rb +2 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b22430fc90715fc9557d4cd0f63bf7cd616c43c4
|
4
|
+
data.tar.gz: aa4ce7df77eb79e02688a208b8efa8cfdf572c60
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0b4d121ab0326143c3651727f7d122006389fd9064810aa38b8b9d251a92bba143ebe9582614fd76e2611e7b1a50e43d76bd904acbf18c0aa3096ada925d74ec
|
7
|
+
data.tar.gz: 512e91b9d64b94615f9fde9fec22145db8a8e8eeac74a663896cb43d1065d5e0f51ff4a61ffbd1e68e89896393f7cfc9a6e93564d302009c1d60988ba591d2e4
|
data/CHANGELOG.md
CHANGED
@@ -4,6 +4,14 @@ All notable changes to this project will be documented in this file. This
|
|
4
4
|
project adheres to [Semantic Versioning](http://semver.org/). This change log is based upon
|
5
5
|
[keep-a-changelog](https://github.com/olivierlacan/keep-a-changelog).
|
6
6
|
|
7
|
+
## [2.6.2](https://github.com/k0kubun/hamlit/compare/v2.6.1...v2.6.2) - 2016-08-27
|
8
|
+
|
9
|
+
### Added
|
10
|
+
|
11
|
+
- Add cdata filter
|
12
|
+
[#84](https://github.com/k0kubun/hamlit/issues/84). *Thanks to @shmargum*
|
13
|
+
- Minimize string allocation on template comipilation using `# frozen_string_literal: true`
|
14
|
+
|
7
15
|
## [2.6.1](https://github.com/k0kubun/hamlit/compare/v2.6.0...v2.6.1) - 2016-08-18
|
8
16
|
|
9
17
|
### Fixed
|
data/lib/hamlit.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
require 'hamlit/attribute_builder'
|
2
3
|
require 'hamlit/attribute_parser'
|
3
4
|
require 'hamlit/ruby_expression'
|
@@ -41,11 +42,11 @@ module Hamlit
|
|
41
42
|
values.select! { |_, exp| exp != nil }
|
42
43
|
|
43
44
|
case key
|
44
|
-
when 'id'
|
45
|
+
when 'id'
|
45
46
|
compile_id!(temple, key, values)
|
46
|
-
when 'class'
|
47
|
+
when 'class'
|
47
48
|
compile_class!(temple, key, values)
|
48
|
-
when 'data'
|
49
|
+
when 'data'
|
49
50
|
compile_data!(temple, key, values)
|
50
51
|
when *AttributeBuilder::BOOLEAN_ATTRIBUTES, /\Adata-/
|
51
52
|
compile_boolean!(temple, key, values)
|
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
require 'hamlit/ruby_expression'
|
2
3
|
|
3
4
|
module Hamlit
|
@@ -28,8 +29,8 @@ module Hamlit
|
|
28
29
|
|
29
30
|
def wrap_bracket(text)
|
30
31
|
text = text.strip
|
31
|
-
return text if text[0] == '{'
|
32
|
-
|
32
|
+
return text if text[0] == '{'
|
33
|
+
"{#{text}}"
|
33
34
|
end
|
34
35
|
|
35
36
|
def parse_key!(tokens)
|
@@ -38,10 +39,10 @@ module Hamlit
|
|
38
39
|
when :on_sp
|
39
40
|
parse_key!(tokens)
|
40
41
|
when :on_label
|
41
|
-
str.tr(':'
|
42
|
+
str.tr(':', '')
|
42
43
|
when :on_symbeg
|
43
44
|
_, _, key = tokens.shift
|
44
|
-
assert_type!(tokens.shift, :on_tstring_end) if str != ':'
|
45
|
+
assert_type!(tokens.shift, :on_tstring_end) if str != ':'
|
45
46
|
skip_until_hash_rocket!(tokens)
|
46
47
|
key
|
47
48
|
when :on_tstring_beg
|
@@ -64,7 +65,7 @@ module Hamlit
|
|
64
65
|
def skip_until_hash_rocket!(tokens)
|
65
66
|
until tokens.empty?
|
66
67
|
_, type, str = tokens.shift
|
67
|
-
break if type == :on_op && str == '=>'
|
68
|
+
break if type == :on_op && str == '=>'
|
68
69
|
end
|
69
70
|
end
|
70
71
|
|
data/lib/hamlit/cli.rb
CHANGED
data/lib/hamlit/compiler.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
module Hamlit
|
2
3
|
class Compiler
|
3
4
|
class ChildrenCompiler
|
@@ -101,7 +102,7 @@ module Hamlit
|
|
101
102
|
when :script
|
102
103
|
node.children.empty? && !nuke_inner_whitespace?(node)
|
103
104
|
when :filter
|
104
|
-
!%w[ruby].
|
105
|
+
!%w[ruby].include?(node.value[:name])
|
105
106
|
else
|
106
107
|
false
|
107
108
|
end
|
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
require 'hamlit/ruby_expression'
|
2
3
|
require 'hamlit/static_analyzer'
|
3
4
|
require 'hamlit/string_splitter'
|
@@ -69,7 +70,7 @@ module Hamlit
|
|
69
70
|
[:multi,
|
70
71
|
[:code, "#{var} = (#{node.value[:text]}"],
|
71
72
|
[:newline],
|
72
|
-
[:code, ')'
|
73
|
+
[:code, ')'],
|
73
74
|
]
|
74
75
|
else
|
75
76
|
[:multi,
|
@@ -84,7 +85,7 @@ module Hamlit
|
|
84
85
|
if !node.value[:escape_html] && node.value[:preserve]
|
85
86
|
result = find_and_preserve(result)
|
86
87
|
else
|
87
|
-
result =
|
88
|
+
result = "(#{result}).to_s"
|
88
89
|
end
|
89
90
|
[:escape, node.value[:escape_html], [:dynamic, result]]
|
90
91
|
end
|
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
require 'hamlit/parser/haml_util'
|
2
3
|
require 'hamlit/attribute_compiler'
|
3
4
|
require 'hamlit/static_analyzer'
|
@@ -35,7 +36,7 @@ module Hamlit
|
|
35
36
|
[:multi,
|
36
37
|
[:code, "#{var} = (#{node.value[:value]}"],
|
37
38
|
[:newline],
|
38
|
-
[:code, ')'
|
39
|
+
[:code, ')'],
|
39
40
|
[:escape, node.value[:escape_html], [:dynamic, var]]
|
40
41
|
]
|
41
42
|
else
|
data/lib/hamlit/engine.rb
CHANGED
data/lib/hamlit/error.rb
CHANGED
data/lib/hamlit/escapable.rb
CHANGED
data/lib/hamlit/filters.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
require 'hamlit/filters/base'
|
2
3
|
require 'hamlit/filters/text_base'
|
3
4
|
require 'hamlit/filters/tilt_base'
|
@@ -13,6 +14,7 @@ require 'hamlit/filters/preserve'
|
|
13
14
|
require 'hamlit/filters/ruby'
|
14
15
|
require 'hamlit/filters/sass'
|
15
16
|
require 'hamlit/filters/scss'
|
17
|
+
require 'hamlit/filters/cdata'
|
16
18
|
|
17
19
|
module Hamlit
|
18
20
|
class Filters
|
@@ -48,6 +50,7 @@ module Hamlit
|
|
48
50
|
register :ruby, Ruby
|
49
51
|
register :sass, Sass
|
50
52
|
register :scss, Scss
|
53
|
+
register :cdata, Cdata
|
51
54
|
|
52
55
|
def initialize(options = {})
|
53
56
|
@options = options
|
data/lib/hamlit/filters/base.rb
CHANGED
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
module Hamlit
|
3
|
+
class Filters
|
4
|
+
class Cdata < TextBase
|
5
|
+
def compile(node)
|
6
|
+
compile_cdata(node)
|
7
|
+
end
|
8
|
+
|
9
|
+
private
|
10
|
+
|
11
|
+
def compile_cdata(node)
|
12
|
+
temple = [:multi]
|
13
|
+
temple << [:static, "<![CDATA[\n"]
|
14
|
+
compile_text!(temple, node, ' ')
|
15
|
+
temple << [:static, "\n]]>"]
|
16
|
+
temple
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -1,12 +1,13 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
module Hamlit
|
2
3
|
class Filters
|
3
4
|
class Coffee < TiltBase
|
4
5
|
def compile(node)
|
5
6
|
require 'tilt/coffee' if explicit_require?
|
6
7
|
temple = [:multi]
|
7
|
-
temple << [:static, "<script>\n"
|
8
|
+
temple << [:static, "<script>\n"]
|
8
9
|
temple << compile_with_tilt(node, 'coffee', indent_width: 2)
|
9
|
-
temple << [:static, "</script>"
|
10
|
+
temple << [:static, "</script>"]
|
10
11
|
temple
|
11
12
|
end
|
12
13
|
end
|
data/lib/hamlit/filters/css.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
module Hamlit
|
2
3
|
class Filters
|
3
4
|
class Css < TextBase
|
@@ -14,17 +15,17 @@ module Hamlit
|
|
14
15
|
|
15
16
|
def compile_html(node)
|
16
17
|
temple = [:multi]
|
17
|
-
temple << [:static, "<style>\n"
|
18
|
-
compile_text!(temple, node, ' '
|
19
|
-
temple << [:static, "\n</style>"
|
18
|
+
temple << [:static, "<style>\n"]
|
19
|
+
compile_text!(temple, node, ' ')
|
20
|
+
temple << [:static, "\n</style>"]
|
20
21
|
temple
|
21
22
|
end
|
22
23
|
|
23
24
|
def compile_xhtml(node)
|
24
25
|
temple = [:multi]
|
25
|
-
temple << [:static, "<style type='text/css'>\n /*<![CDATA[*/\n"
|
26
|
-
compile_text!(temple, node, ' '
|
27
|
-
temple << [:static, "\n /*]]>*/\n</style>"
|
26
|
+
temple << [:static, "<style type='text/css'>\n /*<![CDATA[*/\n"]
|
27
|
+
compile_text!(temple, node, ' ')
|
28
|
+
temple << [:static, "\n /*]]>*/\n</style>"]
|
28
29
|
temple
|
29
30
|
end
|
30
31
|
end
|
data/lib/hamlit/filters/erb.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
module Hamlit
|
2
3
|
class Filters
|
3
4
|
class Javascript < TextBase
|
@@ -14,17 +15,17 @@ module Hamlit
|
|
14
15
|
|
15
16
|
def compile_html(node)
|
16
17
|
temple = [:multi]
|
17
|
-
temple << [:static, "<script>\n"
|
18
|
-
compile_text!(temple, node, ' '
|
19
|
-
temple << [:static, "\n</script>"
|
18
|
+
temple << [:static, "<script>\n"]
|
19
|
+
compile_text!(temple, node, ' ')
|
20
|
+
temple << [:static, "\n</script>"]
|
20
21
|
temple
|
21
22
|
end
|
22
23
|
|
23
24
|
def compile_xhtml(node)
|
24
25
|
temple = [:multi]
|
25
|
-
temple << [:static, "<script type='text/javascript'>\n //<![CDATA[\n"
|
26
|
-
compile_text!(temple, node, ' '
|
27
|
-
temple << [:static, "\n //]]>\n</script>"
|
26
|
+
temple << [:static, "<script type='text/javascript'>\n //<![CDATA[\n"]
|
27
|
+
compile_text!(temple, node, ' ')
|
28
|
+
temple << [:static, "\n //]]>\n</script>"]
|
28
29
|
temple
|
29
30
|
end
|
30
31
|
end
|
data/lib/hamlit/filters/less.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
# LESS support is deprecated since it requires therubyracer.gem,
|
2
3
|
# which is hard to maintain.
|
3
4
|
#
|
@@ -9,9 +10,9 @@ module Hamlit
|
|
9
10
|
def compile(node)
|
10
11
|
require 'tilt/less' if explicit_require?
|
11
12
|
temple = [:multi]
|
12
|
-
temple << [:static, "<style>\n"
|
13
|
+
temple << [:static, "<style>\n"]
|
13
14
|
temple << compile_with_tilt(node, 'less', indent_width: 2)
|
14
|
-
temple << [:static,
|
15
|
+
temple << [:static, '</style>']
|
15
16
|
temple
|
16
17
|
end
|
17
18
|
end
|
data/lib/hamlit/filters/plain.rb
CHANGED
data/lib/hamlit/filters/ruby.rb
CHANGED
data/lib/hamlit/filters/sass.rb
CHANGED
@@ -1,12 +1,13 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
module Hamlit
|
2
3
|
class Filters
|
3
4
|
class Sass < TiltBase
|
4
5
|
def compile(node)
|
5
6
|
require 'tilt/sass' if explicit_require?
|
6
7
|
temple = [:multi]
|
7
|
-
temple << [:static, "<style>\n"
|
8
|
+
temple << [:static, "<style>\n"]
|
8
9
|
temple << compile_with_tilt(node, 'sass', indent_width: 2)
|
9
|
-
temple << [:static, "</style>"
|
10
|
+
temple << [:static, "</style>"]
|
10
11
|
temple
|
11
12
|
end
|
12
13
|
end
|
data/lib/hamlit/filters/scss.rb
CHANGED
@@ -1,12 +1,13 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
module Hamlit
|
2
3
|
class Filters
|
3
4
|
class Scss < TiltBase
|
4
5
|
def compile(node)
|
5
6
|
require 'tilt/sass' if explicit_require?
|
6
7
|
temple = [:multi]
|
7
|
-
temple << [:static, "<style>\n"
|
8
|
+
temple << [:static, "<style>\n"]
|
8
9
|
temple << compile_with_tilt(node, 'scss', indent_width: 2)
|
9
|
-
temple << [:static, "</style>"
|
10
|
+
temple << [:static, "</style>"]
|
10
11
|
temple
|
11
12
|
end
|
12
13
|
end
|
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
require 'tilt'
|
2
3
|
|
3
4
|
module Hamlit
|
@@ -6,7 +7,7 @@ module Hamlit
|
|
6
7
|
def self.render(name, source, indent_width: 0)
|
7
8
|
text = ::Tilt["t.#{name}"].new { source }.render
|
8
9
|
return text if indent_width == 0
|
9
|
-
text.gsub!(/^/, ' '
|
10
|
+
text.gsub!(/^/, ' ' * indent_width)
|
10
11
|
end
|
11
12
|
|
12
13
|
def explicit_require?
|
data/lib/hamlit/helpers.rb
CHANGED
data/lib/hamlit/html.rb
CHANGED
data/lib/hamlit/identity.rb
CHANGED
data/lib/hamlit/object_ref.rb
CHANGED
data/lib/hamlit/parser.rb
CHANGED
data/lib/hamlit/rails_helpers.rb
CHANGED
data/lib/hamlit/railtie.rb
CHANGED
data/lib/hamlit/template.rb
CHANGED
data/lib/hamlit/utils.rb
CHANGED
data/lib/hamlit/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hamlit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.6.
|
4
|
+
version: 2.6.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Takashi Kokubun
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-08-
|
11
|
+
date: 2016-08-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: temple
|
@@ -309,6 +309,7 @@ files:
|
|
309
309
|
- lib/hamlit/escapable.rb
|
310
310
|
- lib/hamlit/filters.rb
|
311
311
|
- lib/hamlit/filters/base.rb
|
312
|
+
- lib/hamlit/filters/cdata.rb
|
312
313
|
- lib/hamlit/filters/coffee.rb
|
313
314
|
- lib/hamlit/filters/css.rb
|
314
315
|
- lib/hamlit/filters/erb.rb
|