better_html 1.0.10 → 1.0.11

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: '059cd51e9cb5795f9069af7f645bfd38a595ab37'
4
- data.tar.gz: a123b84e38a23923558c8d2c116e4f85dd779328
3
+ metadata.gz: 5a62a4416eaa383372a21c1b8f90494d681ad7ca
4
+ data.tar.gz: bf03706d26596c0b03bec716d2b55f35324221b3
5
5
  SHA512:
6
- metadata.gz: ae4b109983ee2b1a1e13b4ad061dae11aa52be470918cd9746f7b49a38f081a28322f73bc198da9f9d3fd8cd3daa266589fd0aad5613a0c0150f5f48b705c60f
7
- data.tar.gz: acb00111001a7deb8a41ecbdcf103daa8d450e4f8cdfbce0c343bd3a9f5081952210b333a4ef355beeb4d3f9a5225db0aeb49ae0df5680b557f8ee98d5df5518
6
+ metadata.gz: 8ede71b45ba3cc636f1d77e76eab6e22eb539014a4fe049e9f91796bb3efc7c8c8d6629f6b2cb8f6a80738a26a892d39341b0c578b28d222a353b945f18266ac
7
+ data.tar.gz: 788384054b7e79a080dda17b7cbb3658e14ba1034849ca855fe9e144ac47126246631984ab509c986515e82a063133a647bf94b5f3986b0b3bf8aebb40ffbeaf
@@ -14,7 +14,7 @@ module BetterHtml
14
14
  def no_javascript_tag_helper(node)
15
15
  erb_nodes(node).each do |erb_node, indicator_node, code_node|
16
16
  indicator = indicator_node&.loc&.source
17
- next if indicator == '#'
17
+ next if indicator == '#' || indicator == '%'
18
18
  source = code_node.loc.source
19
19
 
20
20
  ruby_node = begin
@@ -25,7 +25,7 @@ module BetterHtml
25
25
  erb_nodes(node).each do |erb_node, indicator_node, code_node|
26
26
  next unless indicator_node.present?
27
27
  indicator = indicator_node.loc.source
28
- next if indicator == '#'
28
+ next if indicator == '#' || indicator == '%'
29
29
  source = code_node.loc.source
30
30
 
31
31
  ruby_node = begin
@@ -67,7 +67,7 @@ module BetterHtml
67
67
  def validate_text_node(text_node)
68
68
  erb_nodes(text_node).each do |erb_node, indicator_node, code_node|
69
69
  indicator = indicator_node&.loc&.source
70
- next if indicator == '#'
70
+ next if indicator == '#' || indicator == '%'
71
71
  source = code_node.loc.source
72
72
 
73
73
  ruby_node = begin
@@ -29,7 +29,8 @@ module BetterHtml
29
29
 
30
30
  def add_code(code)
31
31
  if code[0] == '%'
32
- add_text("<%#{code}%>")
32
+ add_erb_tokens(nil, '%', code[1..-1], nil)
33
+ append("<%#{code}%>")
33
34
  else
34
35
  _, ltrim_or_comment, code, rtrim = *STMT_TRIM_MATCHER.match(code)
35
36
  ltrim = ltrim_or_comment if ltrim_or_comment == '-'
@@ -1,3 +1,3 @@
1
1
  module BetterHtml
2
- VERSION = "1.0.10"
2
+ VERSION = "1.0.11"
3
3
  end
@@ -152,19 +152,14 @@ module BetterHtml
152
152
 
153
153
  test "escaped opening ERB tag <%%" do
154
154
  scanner = HtmlErb.new(buffer("just some <%%= text %> no erb"))
155
- assert_equal 11, scanner.tokens.size
155
+ assert_equal 6, scanner.tokens.size
156
156
 
157
157
  assert_attributes ({ type: :text, loc: { line: 1, source: "just some " } }), scanner.tokens[0]
158
- assert_attributes ({ type: :tag_start, loc: { line: 1, source: '<' } }), scanner.tokens[1]
159
- assert_attributes ({ type: :tag_name, loc: { line: 1, source: '%%=' } }), scanner.tokens[2]
160
- assert_attributes ({ type: :whitespace, loc: { line: 1, source: " " } }), scanner.tokens[3]
161
- assert_attributes ({ type: :attribute_name, loc: { line: 1, source: "text" } }), scanner.tokens[4]
162
- assert_attributes ({ type: :whitespace, loc: { line: 1, source: " " } }), scanner.tokens[5]
163
- assert_attributes ({ type: :malformed, loc: { line: 1, source: "%>" } }), scanner.tokens[6]
164
- assert_attributes ({ type: :whitespace, loc: { line: 1, source: " " } }), scanner.tokens[7]
165
- assert_attributes ({ type: :attribute_name, loc: { line: 1, source: "no" } }), scanner.tokens[8]
166
- assert_attributes ({ type: :whitespace, loc: { line: 1, source: " " } }), scanner.tokens[9]
167
- assert_attributes ({ type: :attribute_name, loc: { line: 1, source: "erb" } }), scanner.tokens[10]
158
+ assert_attributes ({ type: :erb_begin, loc: { line: 1, source: '<%' } }), scanner.tokens[1]
159
+ assert_attributes ({ type: :indicator, loc: { line: 1, source: "%" } }), scanner.tokens[2]
160
+ assert_attributes ({ type: :code, loc: { line: 1, source: "= text " } }), scanner.tokens[3]
161
+ assert_attributes ({ type: :erb_end, loc: { line: 1, source: "%>" } }), scanner.tokens[4]
162
+ assert_attributes ({ type: :text, loc: { line: 1, source: " no erb" } }), scanner.tokens[5]
168
163
  end
169
164
 
170
165
  private
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: better_html
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.10
4
+ version: 1.0.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Francois Chagnon
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-05-08 00:00:00.000000000 Z
11
+ date: 2018-05-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ast