better_html 1.0.15 → 2.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (99) hide show
  1. checksums.yaml +4 -4
  2. data/MIT-LICENSE +1 -0
  3. data/Rakefile +19 -14
  4. data/ext/better_html_ext/better_html.h +1 -0
  5. data/ext/better_html_ext/extconf.rb +16 -0
  6. data/ext/better_html_ext/html_tokenizer.c +12 -0
  7. data/ext/better_html_ext/html_tokenizer.h +7 -0
  8. data/ext/better_html_ext/parser.c +793 -0
  9. data/ext/better_html_ext/parser.h +93 -0
  10. data/ext/better_html_ext/tokenizer.c +717 -0
  11. data/ext/better_html_ext/tokenizer.h +80 -0
  12. data/lib/better_html/ast/iterator.rb +14 -9
  13. data/lib/better_html/ast/node.rb +4 -2
  14. data/lib/better_html/better_erb/erubi_implementation.rb +43 -39
  15. data/lib/better_html/better_erb/runtime_checks.rb +140 -133
  16. data/lib/better_html/better_erb/validated_output_buffer.rb +30 -22
  17. data/lib/better_html/better_erb.rb +47 -56
  18. data/lib/better_html/config.rb +7 -4
  19. data/lib/better_html/errors.rb +15 -2
  20. data/lib/better_html/helpers.rb +7 -3
  21. data/lib/better_html/html_attributes.rb +6 -2
  22. data/lib/better_html/parser.rb +22 -14
  23. data/lib/better_html/railtie.rb +8 -4
  24. data/lib/better_html/test_helper/ruby_node.rb +15 -10
  25. data/lib/better_html/test_helper/safe_erb/allowed_script_type.rb +8 -4
  26. data/lib/better_html/test_helper/safe_erb/base.rb +12 -9
  27. data/lib/better_html/test_helper/safe_erb/no_javascript_tag_helper.rb +7 -3
  28. data/lib/better_html/test_helper/safe_erb/no_statements.rb +7 -3
  29. data/lib/better_html/test_helper/safe_erb/script_interpolation.rb +9 -4
  30. data/lib/better_html/test_helper/safe_erb/tag_interpolation.rb +23 -20
  31. data/lib/better_html/test_helper/safe_erb_tester.rb +34 -32
  32. data/lib/better_html/test_helper/safe_lodash_tester.rb +36 -35
  33. data/lib/better_html/test_helper/safety_error.rb +2 -0
  34. data/lib/better_html/tokenizer/base_erb.rb +19 -15
  35. data/lib/better_html/tokenizer/html_erb.rb +3 -2
  36. data/lib/better_html/tokenizer/html_lodash.rb +22 -14
  37. data/lib/better_html/tokenizer/javascript_erb.rb +3 -1
  38. data/lib/better_html/tokenizer/location.rb +17 -6
  39. data/lib/better_html/tokenizer/token.rb +2 -0
  40. data/lib/better_html/tokenizer/token_array.rb +8 -8
  41. data/lib/better_html/tree/attribute.rb +10 -6
  42. data/lib/better_html/tree/attributes_list.rb +9 -5
  43. data/lib/better_html/tree/tag.rb +10 -6
  44. data/lib/better_html/version.rb +3 -1
  45. data/lib/better_html.rb +19 -17
  46. data/lib/tasks/better_html_tasks.rake +1 -0
  47. metadata +39 -147
  48. data/lib/better_html/better_erb/erubis_implementation.rb +0 -44
  49. data/test/better_html/better_erb/implementation_test.rb +0 -406
  50. data/test/better_html/errors_test.rb +0 -13
  51. data/test/better_html/helpers_test.rb +0 -49
  52. data/test/better_html/parser_test.rb +0 -314
  53. data/test/better_html/test_helper/ruby_node_test.rb +0 -288
  54. data/test/better_html/test_helper/safe_erb/allowed_script_type_test.rb +0 -46
  55. data/test/better_html/test_helper/safe_erb/no_javascript_tag_helper_test.rb +0 -37
  56. data/test/better_html/test_helper/safe_erb/no_statements_test.rb +0 -129
  57. data/test/better_html/test_helper/safe_erb/script_interpolation_test.rb +0 -149
  58. data/test/better_html/test_helper/safe_erb/tag_interpolation_test.rb +0 -303
  59. data/test/better_html/test_helper/safe_lodash_tester_test.rb +0 -90
  60. data/test/better_html/tokenizer/html_erb_test.rb +0 -180
  61. data/test/better_html/tokenizer/html_lodash_test.rb +0 -98
  62. data/test/better_html/tokenizer/location_test.rb +0 -75
  63. data/test/better_html/tokenizer/token_array_test.rb +0 -146
  64. data/test/better_html/tokenizer/token_test.rb +0 -15
  65. data/test/dummy/README.rdoc +0 -28
  66. data/test/dummy/Rakefile +0 -6
  67. data/test/dummy/app/assets/javascripts/application.js +0 -13
  68. data/test/dummy/app/assets/stylesheets/application.css +0 -15
  69. data/test/dummy/app/controllers/application_controller.rb +0 -5
  70. data/test/dummy/app/helpers/application_helper.rb +0 -2
  71. data/test/dummy/app/views/layouts/application.html.erb +0 -14
  72. data/test/dummy/bin/bundle +0 -3
  73. data/test/dummy/bin/rails +0 -4
  74. data/test/dummy/bin/rake +0 -4
  75. data/test/dummy/bin/setup +0 -29
  76. data/test/dummy/config/application.rb +0 -26
  77. data/test/dummy/config/boot.rb +0 -5
  78. data/test/dummy/config/database.yml +0 -25
  79. data/test/dummy/config/environment.rb +0 -5
  80. data/test/dummy/config/environments/development.rb +0 -41
  81. data/test/dummy/config/environments/production.rb +0 -79
  82. data/test/dummy/config/environments/test.rb +0 -42
  83. data/test/dummy/config/initializers/assets.rb +0 -11
  84. data/test/dummy/config/initializers/backtrace_silencers.rb +0 -7
  85. data/test/dummy/config/initializers/cookies_serializer.rb +0 -3
  86. data/test/dummy/config/initializers/filter_parameter_logging.rb +0 -4
  87. data/test/dummy/config/initializers/inflections.rb +0 -16
  88. data/test/dummy/config/initializers/mime_types.rb +0 -4
  89. data/test/dummy/config/initializers/session_store.rb +0 -3
  90. data/test/dummy/config/initializers/wrap_parameters.rb +0 -14
  91. data/test/dummy/config/locales/en.yml +0 -23
  92. data/test/dummy/config/routes.rb +0 -56
  93. data/test/dummy/config/secrets.yml +0 -22
  94. data/test/dummy/config.ru +0 -4
  95. data/test/dummy/public/404.html +0 -67
  96. data/test/dummy/public/422.html +0 -67
  97. data/test/dummy/public/500.html +0 -66
  98. data/test/dummy/public/favicon.ico +0 -0
  99. data/test/test_helper.rb +0 -29
@@ -1,19 +1,23 @@
1
- require 'ast'
1
+ # frozen_string_literal: true
2
+
3
+ require "ast"
2
4
 
3
5
  module BetterHtml
4
6
  module Tree
5
7
  class Attribute
6
8
  attr_reader :node, :name_node, :equal_node, :value_node
7
9
 
10
+ class << self
11
+ def from_node(node)
12
+ new(node)
13
+ end
14
+ end
15
+
8
16
  def initialize(node)
9
17
  @node = node
10
18
  @name_node, @equal_node, @value_node = *node if @node.type == :attribute
11
19
  end
12
20
 
13
- def self.from_node(node)
14
- new(node)
15
- end
16
-
17
21
  def erb?
18
22
  @node.type == :erb
19
23
  end
@@ -27,7 +31,7 @@ module BetterHtml
27
31
  end
28
32
 
29
33
  def value
30
- parts = value_node.to_a.reject{ |node| node.is_a?(::AST::Node) && node.type == :quote }
34
+ parts = value_node.to_a.reject { |node| node.is_a?(::AST::Node) && node.type == :quote }
31
35
  parts.map { |s| s.is_a?(::AST::Node) ? s.loc.source : CGI.unescapeHTML(s) }.join
32
36
  end
33
37
  end
@@ -1,14 +1,18 @@
1
- require 'better_html/tree/attribute'
1
+ # frozen_string_literal: true
2
+
3
+ require "better_html/tree/attribute"
2
4
 
3
5
  module BetterHtml
4
6
  module Tree
5
7
  class AttributesList
6
- def initialize(list)
7
- @list = list || []
8
+ class << self
9
+ def from_nodes(nodes)
10
+ new(nodes&.map { |node| Tree::Attribute.from_node(node) })
11
+ end
8
12
  end
9
13
 
10
- def self.from_nodes(nodes)
11
- new(nodes&.map { |node| Tree::Attribute.from_node(node) })
14
+ def initialize(list)
15
+ @list = list || []
12
16
  end
13
17
 
14
18
  def [](name)
@@ -1,20 +1,24 @@
1
- require 'better_html/tree/attributes_list'
2
- require 'better_html/ast/iterator'
1
+ # frozen_string_literal: true
2
+
3
+ require "better_html/tree/attributes_list"
4
+ require "better_html/ast/iterator"
3
5
 
4
6
  module BetterHtml
5
7
  module Tree
6
8
  class Tag
7
9
  attr_reader :node, :start_solidus, :name_node, :attributes_node, :end_solidus
8
10
 
11
+ class << self
12
+ def from_node(node)
13
+ new(node)
14
+ end
15
+ end
16
+
9
17
  def initialize(node)
10
18
  @node = node
11
19
  @start_solidus, @name_node, @attributes_node, @end_solidus = *node
12
20
  end
13
21
 
14
- def self.from_node(node)
15
- new(node)
16
- end
17
-
18
22
  def loc
19
23
  @node.loc
20
24
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module BetterHtml
2
- VERSION = "1.0.15"
4
+ VERSION = "2.0.1"
3
5
  end
data/lib/better_html.rb CHANGED
@@ -1,25 +1,27 @@
1
- require 'active_support/core_ext/hash/keys'
2
- require 'active_support/core_ext/module/delegation'
3
- require 'active_support/core_ext/class/attribute_accessors'
1
+ # frozen_string_literal: true
2
+
3
+ require "active_support/core_ext/hash/keys"
4
+ require "active_support/core_ext/module/delegation"
5
+ require "active_support/core_ext/class/attribute_accessors"
4
6
 
5
7
  module BetterHtml
6
- def self.configure
7
- yield config if block_given?
8
- end
8
+ class << self
9
+ attr_writer :config
9
10
 
10
- def self.config
11
- @config ||= Config.new
12
- end
11
+ def config
12
+ @config ||= Config.new
13
+ end
13
14
 
14
- def self.config=(new_config)
15
- @config = new_config
15
+ def configure
16
+ yield config if block_given?
17
+ end
16
18
  end
17
19
  end
18
20
 
19
- require 'better_html/version'
20
- require 'better_html/config'
21
- require 'better_html/helpers'
22
- require 'better_html/errors'
23
- require 'better_html/html_attributes'
21
+ require "better_html/version"
22
+ require "better_html/config"
23
+ require "better_html/helpers"
24
+ require "better_html/errors"
25
+ require "better_html/html_attributes"
24
26
 
25
- require 'better_html/railtie' if defined?(Rails)
27
+ require "better_html/railtie" if defined?(Rails)
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  # desc "Explaining what the task does"
2
3
  # task :better_html do
3
4
  # # Task goes here
metadata CHANGED
@@ -1,71 +1,71 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: better_html
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.15
4
+ version: 2.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Francois Chagnon
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-05-19 00:00:00.000000000 Z
11
+ date: 2022-08-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: ast
14
+ name: actionview
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '2.0'
19
+ version: '6.0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: '2.0'
26
+ version: '6.0'
27
27
  - !ruby/object:Gem::Dependency
28
- name: erubi
28
+ name: activesupport
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "~>"
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: '1.4'
33
+ version: '6.0'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - "~>"
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
- version: '1.4'
40
+ version: '6.0'
41
41
  - !ruby/object:Gem::Dependency
42
- name: activesupport
42
+ name: ast
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ">="
45
+ - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '4.0'
47
+ version: '2.0'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ">="
52
+ - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '4.0'
54
+ version: '2.0'
55
55
  - !ruby/object:Gem::Dependency
56
- name: actionview
56
+ name: erubi
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ">="
59
+ - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: '4.0'
61
+ version: '1.4'
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - ">="
66
+ - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: '4.0'
68
+ version: '1.4'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: parser
71
71
  requirement: !ruby/object:Gem::Requirement
@@ -94,50 +94,44 @@ dependencies:
94
94
  - - ">="
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0'
97
- - !ruby/object:Gem::Dependency
98
- name: html_tokenizer
99
- requirement: !ruby/object:Gem::Requirement
100
- requirements:
101
- - - "~>"
102
- - !ruby/object:Gem::Version
103
- version: 0.0.6
104
- type: :runtime
105
- prerelease: false
106
- version_requirements: !ruby/object:Gem::Requirement
107
- requirements:
108
- - - "~>"
109
- - !ruby/object:Gem::Version
110
- version: 0.0.6
111
97
  - !ruby/object:Gem::Dependency
112
98
  name: rake
113
99
  requirement: !ruby/object:Gem::Requirement
114
100
  requirements:
115
101
  - - "~>"
116
102
  - !ruby/object:Gem::Version
117
- version: '0'
103
+ version: '13'
118
104
  type: :development
119
105
  prerelease: false
120
106
  version_requirements: !ruby/object:Gem::Requirement
121
107
  requirements:
122
108
  - - "~>"
123
109
  - !ruby/object:Gem::Version
124
- version: '0'
110
+ version: '13'
125
111
  description: Better HTML for Rails. Provides sane html helpers that make it easier
126
112
  to do the right thing.
127
113
  email:
128
- - francois.chagnon@shopify.com
114
+ - ruby@shopify.com
129
115
  executables: []
130
- extensions: []
116
+ extensions:
117
+ - ext/better_html_ext/extconf.rb
131
118
  extra_rdoc_files: []
132
119
  files:
133
120
  - MIT-LICENSE
134
121
  - Rakefile
122
+ - ext/better_html_ext/better_html.h
123
+ - ext/better_html_ext/extconf.rb
124
+ - ext/better_html_ext/html_tokenizer.c
125
+ - ext/better_html_ext/html_tokenizer.h
126
+ - ext/better_html_ext/parser.c
127
+ - ext/better_html_ext/parser.h
128
+ - ext/better_html_ext/tokenizer.c
129
+ - ext/better_html_ext/tokenizer.h
135
130
  - lib/better_html.rb
136
131
  - lib/better_html/ast/iterator.rb
137
132
  - lib/better_html/ast/node.rb
138
133
  - lib/better_html/better_erb.rb
139
134
  - lib/better_html/better_erb/erubi_implementation.rb
140
- - lib/better_html/better_erb/erubis_implementation.rb
141
135
  - lib/better_html/better_erb/runtime_checks.rb
142
136
  - lib/better_html/better_erb/validated_output_buffer.rb
143
137
  - lib/better_html/config.rb
@@ -168,64 +162,13 @@ files:
168
162
  - lib/better_html/tree/tag.rb
169
163
  - lib/better_html/version.rb
170
164
  - lib/tasks/better_html_tasks.rake
171
- - test/better_html/better_erb/implementation_test.rb
172
- - test/better_html/errors_test.rb
173
- - test/better_html/helpers_test.rb
174
- - test/better_html/parser_test.rb
175
- - test/better_html/test_helper/ruby_node_test.rb
176
- - test/better_html/test_helper/safe_erb/allowed_script_type_test.rb
177
- - test/better_html/test_helper/safe_erb/no_javascript_tag_helper_test.rb
178
- - test/better_html/test_helper/safe_erb/no_statements_test.rb
179
- - test/better_html/test_helper/safe_erb/script_interpolation_test.rb
180
- - test/better_html/test_helper/safe_erb/tag_interpolation_test.rb
181
- - test/better_html/test_helper/safe_lodash_tester_test.rb
182
- - test/better_html/tokenizer/html_erb_test.rb
183
- - test/better_html/tokenizer/html_lodash_test.rb
184
- - test/better_html/tokenizer/location_test.rb
185
- - test/better_html/tokenizer/token_array_test.rb
186
- - test/better_html/tokenizer/token_test.rb
187
- - test/dummy/README.rdoc
188
- - test/dummy/Rakefile
189
- - test/dummy/app/assets/javascripts/application.js
190
- - test/dummy/app/assets/stylesheets/application.css
191
- - test/dummy/app/controllers/application_controller.rb
192
- - test/dummy/app/helpers/application_helper.rb
193
- - test/dummy/app/views/layouts/application.html.erb
194
- - test/dummy/bin/bundle
195
- - test/dummy/bin/rails
196
- - test/dummy/bin/rake
197
- - test/dummy/bin/setup
198
- - test/dummy/config.ru
199
- - test/dummy/config/application.rb
200
- - test/dummy/config/boot.rb
201
- - test/dummy/config/database.yml
202
- - test/dummy/config/environment.rb
203
- - test/dummy/config/environments/development.rb
204
- - test/dummy/config/environments/production.rb
205
- - test/dummy/config/environments/test.rb
206
- - test/dummy/config/initializers/assets.rb
207
- - test/dummy/config/initializers/backtrace_silencers.rb
208
- - test/dummy/config/initializers/cookies_serializer.rb
209
- - test/dummy/config/initializers/filter_parameter_logging.rb
210
- - test/dummy/config/initializers/inflections.rb
211
- - test/dummy/config/initializers/mime_types.rb
212
- - test/dummy/config/initializers/session_store.rb
213
- - test/dummy/config/initializers/wrap_parameters.rb
214
- - test/dummy/config/locales/en.yml
215
- - test/dummy/config/routes.rb
216
- - test/dummy/config/secrets.yml
217
- - test/dummy/public/404.html
218
- - test/dummy/public/422.html
219
- - test/dummy/public/500.html
220
- - test/dummy/public/favicon.ico
221
- - test/test_helper.rb
222
165
  homepage: https://github.com/Shopify/better-html
223
166
  licenses:
224
167
  - MIT
225
168
  metadata:
226
169
  bug_tracker_uri: https://github.com/Shopify/better-html/issues
227
170
  changelog_uri: https://github.com/Shopify/better-html/releases
228
- source_code_uri: https://github.com/Shopify/better-html/tree/v1.0.15
171
+ source_code_uri: https://github.com/Shopify/better-html/tree/v2.0.1
229
172
  allowed_push_host: https://rubygems.org
230
173
  post_install_message:
231
174
  rdoc_options: []
@@ -235,66 +178,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
235
178
  requirements:
236
179
  - - ">="
237
180
  - !ruby/object:Gem::Version
238
- version: '0'
181
+ version: 2.7.0
239
182
  required_rubygems_version: !ruby/object:Gem::Requirement
240
183
  requirements:
241
184
  - - ">="
242
185
  - !ruby/object:Gem::Version
243
186
  version: '0'
244
187
  requirements: []
245
- rubygems_version: 3.0.3
188
+ rubygems_version: 3.3.3
246
189
  signing_key:
247
190
  specification_version: 4
248
191
  summary: Better HTML for Rails.
249
- test_files:
250
- - test/test_helper.rb
251
- - test/better_html/helpers_test.rb
252
- - test/better_html/better_erb/implementation_test.rb
253
- - test/better_html/errors_test.rb
254
- - test/better_html/parser_test.rb
255
- - test/better_html/tokenizer/token_array_test.rb
256
- - test/better_html/tokenizer/token_test.rb
257
- - test/better_html/tokenizer/html_lodash_test.rb
258
- - test/better_html/tokenizer/location_test.rb
259
- - test/better_html/tokenizer/html_erb_test.rb
260
- - test/better_html/test_helper/safe_erb/script_interpolation_test.rb
261
- - test/better_html/test_helper/safe_erb/allowed_script_type_test.rb
262
- - test/better_html/test_helper/safe_erb/no_javascript_tag_helper_test.rb
263
- - test/better_html/test_helper/safe_erb/no_statements_test.rb
264
- - test/better_html/test_helper/safe_erb/tag_interpolation_test.rb
265
- - test/better_html/test_helper/ruby_node_test.rb
266
- - test/better_html/test_helper/safe_lodash_tester_test.rb
267
- - test/dummy/app/controllers/application_controller.rb
268
- - test/dummy/app/helpers/application_helper.rb
269
- - test/dummy/app/views/layouts/application.html.erb
270
- - test/dummy/app/assets/stylesheets/application.css
271
- - test/dummy/app/assets/javascripts/application.js
272
- - test/dummy/bin/bundle
273
- - test/dummy/bin/rake
274
- - test/dummy/bin/rails
275
- - test/dummy/bin/setup
276
- - test/dummy/config/initializers/filter_parameter_logging.rb
277
- - test/dummy/config/initializers/wrap_parameters.rb
278
- - test/dummy/config/initializers/backtrace_silencers.rb
279
- - test/dummy/config/initializers/cookies_serializer.rb
280
- - test/dummy/config/initializers/session_store.rb
281
- - test/dummy/config/initializers/assets.rb
282
- - test/dummy/config/initializers/mime_types.rb
283
- - test/dummy/config/initializers/inflections.rb
284
- - test/dummy/config/secrets.yml
285
- - test/dummy/config/application.rb
286
- - test/dummy/config/database.yml
287
- - test/dummy/config/environment.rb
288
- - test/dummy/config/boot.rb
289
- - test/dummy/config/locales/en.yml
290
- - test/dummy/config/environments/development.rb
291
- - test/dummy/config/environments/test.rb
292
- - test/dummy/config/environments/production.rb
293
- - test/dummy/config/routes.rb
294
- - test/dummy/public/500.html
295
- - test/dummy/public/favicon.ico
296
- - test/dummy/public/422.html
297
- - test/dummy/public/404.html
298
- - test/dummy/Rakefile
299
- - test/dummy/config.ru
300
- - test/dummy/README.rdoc
192
+ test_files: []
@@ -1,44 +0,0 @@
1
- require 'action_view'
2
- require_relative 'runtime_checks'
3
-
4
- class BetterHtml::BetterErb
5
- class ErubisImplementation < ActionView::Template::Handlers::Erubis
6
- include RuntimeChecks
7
-
8
- def add_text(src, text)
9
- return if text.empty?
10
-
11
- if text == "\n"
12
- @parser.parse("\n")
13
- @newline_pending += 1
14
- else
15
- src << "@output_buffer.safe_append='"
16
- src << "\n" * @newline_pending if @newline_pending > 0
17
- src << escape_text(text)
18
- src << "'.freeze;"
19
-
20
- @parser.parse(text) do |*args|
21
- check_token(*args)
22
- end
23
-
24
- @newline_pending = 0
25
- end
26
- end
27
-
28
- def add_expr_literal(src, code)
29
- add_expr_auto_escaped(src, code, true)
30
- end
31
-
32
- def add_expr_escaped(src, code)
33
- add_expr_auto_escaped(src, code, false)
34
- end
35
-
36
- def add_stmt(src, code)
37
- flush_newline_if_pending(src)
38
-
39
- block_check(src, "<%#{code}%>")
40
- @parser.append_placeholder(code)
41
- super
42
- end
43
- end
44
- end