markaby 0.9.0 → 0.9.1

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
- SHA1:
3
- metadata.gz: 455850946266c24fdba0054e72e738909a92f031
4
- data.tar.gz: fb9ea63ab1b9d64366d7af5deda7c4af1c09ec2a
2
+ SHA256:
3
+ metadata.gz: 535329bcc48d16625bfba60bf91d25e9fc40f44821057beeea32b4e49d7271b8
4
+ data.tar.gz: 30e7730d1d4b8c3b7997c9956dda022cd4851cbf16f7a124c4cb1df62eb5b255
5
5
  SHA512:
6
- metadata.gz: 89dd42bd927211894995fc1fd98633345d140d047e379fb647f8c84c88a8cda28fee5677c7fe0283691045659ed8f96a982987e512828f1d2f97fa7fa4f42616
7
- data.tar.gz: 4dcbdfcaa7c11683e572595f24f2cd9267c09d1280a97f38151abaa1e2fdb6bdfc53ae77c04e9cd4a67e8692476a22af11436b9cdb7992136f5bf6d33db886c2
6
+ metadata.gz: 53e7e2a1b89c5c0bfb2e3758a0f3a3235c7b68539787e7722bc862124b52ac28bab464479e2fc605415616b187251dd69d5e6ee38f64fce20186139a782c9c47
7
+ data.tar.gz: c105c5c0d893354d6069c9e18d8694a80673bf97f24ee24ec8c41c99c9c86432362ac51f0d8f7d61d8db423a726a77a6796c51e87552e7859d940faef154e8b7
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- ruby-2.3.1
1
+ ruby-2.7.3
data/.travis.yml CHANGED
@@ -1,16 +1,12 @@
1
1
  language: ruby
2
2
  sudo: false
3
3
  rvm:
4
- - 1.8
5
- - 1.9
6
- - 2.0
7
- - 2.1
8
- - 2.2
9
- - 2.3
10
4
  - 2.4
5
+ - 2.5
6
+ - 2.6
7
+ - 2.7
11
8
  matrix:
12
9
  allow_failures:
13
- - rvm: 2.5
14
10
  - rvm: jruby-9.1.15.0
15
11
  - rvm: rbx-2
16
12
  install: bundle install --without=development --jobs=3 --retry=3
data/CHANGELOG.rdoc CHANGED
@@ -1,3 +1,22 @@
1
+ = HEAD
2
+
3
+ = 0.9.1
4
+
5
+ * update release tasks [tech task]
6
+ * re-release version since code was included in last release
7
+
8
+ = 0.9.0
9
+
10
+ * Add data attributes: https://github.com/markaby/markaby/pull/44 (rahoulb)
11
+
12
+ * Add data + aria attributes
13
+ * Allow creation of custom web components / elements in html5
14
+ my_custom_element prop: "value" =>
15
+ "<my-custom-element prop="value"></my-custom-element>"
16
+ See https://stackoverflow.com/questions/9845011/are-custom-elements-valid-html5
17
+ * split up tag sets into different files
18
+ * add standardrb + use code conventions
19
+
1
20
  = 0.7.1 (2010-08-19)
2
21
 
3
22
  * Rails fixes for form_for called from erb templates
data/Gemfile CHANGED
@@ -1,12 +1,14 @@
1
- source 'https://rubygems.org'
1
+ source "https://rubygems.org"
2
2
 
3
- gem 'builder'
3
+ gem "builder"
4
+
5
+ group :development do
6
+ gem "standardrb"
7
+ end
4
8
 
5
9
  group :test do
6
- gem 'rake'
7
- gem 'rspec'
8
- gem 'test-unit', :platform => [:mri_22, :mri_23, :mri_24, :mri_25]
9
- gem 'byebug', :platform => [:mri_20, :mri_21, :mri_22, :mri_23, :mri_24, :mri_25]
10
- gem 'ruby-debug', :platform => [:mri_18]
11
- gem 'ruby-debug19', :platform => [:mri_19]
10
+ gem "rake"
11
+ gem "rspec"
12
+ gem "test-unit"
13
+ gem "byebug"
12
14
  end
data/Gemfile.lock CHANGED
@@ -1,65 +1,79 @@
1
1
  GEM
2
2
  remote: https://rubygems.org/
3
3
  specs:
4
- archive-tar-minitar (0.6.1)
5
- minitar (~> 0.6)
6
- minitar-cli (~> 0.6)
7
- builder (3.2.2)
8
- byebug (2.7.0)
9
- columnize (~> 0.3)
10
- debugger-linecache (~> 1.2)
11
- columnize (0.9.0)
12
- debugger-linecache (1.2.0)
13
- diff-lcs (1.2.5)
14
- hashie (3.5.7)
15
- linecache (1.3.1)
16
- linecache19 (0.5.12)
17
- ruby_core_source (>= 0.1.4)
18
- minitar (0.6.1)
19
- minitar-cli (0.6.1)
20
- minitar (~> 0.6.0)
21
- powerbar (~> 1.0)
22
- power_assert (1.1.1)
23
- powerbar (1.0.18)
24
- hashie (>= 1.1.0)
25
- rake (10.1.0)
26
- rspec (2.14.1)
27
- rspec-core (~> 2.14.0)
28
- rspec-expectations (~> 2.14.0)
29
- rspec-mocks (~> 2.14.0)
30
- rspec-core (2.14.7)
31
- rspec-expectations (2.14.4)
32
- diff-lcs (>= 1.1.3, < 2.0)
33
- rspec-mocks (2.14.4)
34
- ruby-debug (0.10.4)
35
- columnize (>= 0.1)
36
- ruby-debug-base (~> 0.10.4.0)
37
- ruby-debug-base (0.10.4)
38
- linecache (>= 0.3)
39
- ruby-debug-base19 (0.11.25)
40
- columnize (>= 0.3.1)
41
- linecache19 (>= 0.5.11)
42
- ruby_core_source (>= 0.1.4)
43
- ruby-debug19 (0.11.6)
44
- columnize (>= 0.3.1)
45
- linecache19 (>= 0.5.11)
46
- ruby-debug-base19 (>= 0.11.19)
47
- ruby_core_source (0.1.5)
48
- archive-tar-minitar (>= 0.5.2)
49
- test-unit (3.2.7)
4
+ ast (2.4.2)
5
+ builder (3.2.4)
6
+ byebug (11.1.3)
7
+ diff-lcs (1.5.0)
8
+ json (2.6.3)
9
+ language_server-protocol (3.17.0.3)
10
+ lint_roller (1.0.0)
11
+ parallel (1.23.0)
12
+ parser (3.2.2.1)
13
+ ast (~> 2.4.1)
14
+ power_assert (2.0.3)
15
+ rainbow (3.1.1)
16
+ rake (13.0.6)
17
+ regexp_parser (2.8.0)
18
+ rexml (3.2.5)
19
+ rspec (3.12.0)
20
+ rspec-core (~> 3.12.0)
21
+ rspec-expectations (~> 3.12.0)
22
+ rspec-mocks (~> 3.12.0)
23
+ rspec-core (3.12.2)
24
+ rspec-support (~> 3.12.0)
25
+ rspec-expectations (3.12.3)
26
+ diff-lcs (>= 1.2.0, < 2.0)
27
+ rspec-support (~> 3.12.0)
28
+ rspec-mocks (3.12.5)
29
+ diff-lcs (>= 1.2.0, < 2.0)
30
+ rspec-support (~> 3.12.0)
31
+ rspec-support (3.12.0)
32
+ rubocop (1.50.2)
33
+ json (~> 2.3)
34
+ parallel (~> 1.10)
35
+ parser (>= 3.2.0.0)
36
+ rainbow (>= 2.2.2, < 4.0)
37
+ regexp_parser (>= 1.8, < 3.0)
38
+ rexml (>= 3.2.5, < 4.0)
39
+ rubocop-ast (>= 1.28.0, < 2.0)
40
+ ruby-progressbar (~> 1.7)
41
+ unicode-display_width (>= 2.4.0, < 3.0)
42
+ rubocop-ast (1.28.1)
43
+ parser (>= 3.2.1.0)
44
+ rubocop-performance (1.16.0)
45
+ rubocop (>= 1.7.0, < 2.0)
46
+ rubocop-ast (>= 0.4.0)
47
+ ruby-progressbar (1.13.0)
48
+ standard (1.28.2)
49
+ language_server-protocol (~> 3.17.0.2)
50
+ lint_roller (~> 1.0)
51
+ rubocop (~> 1.50.2)
52
+ standard-custom (~> 1.0.0)
53
+ standard-performance (~> 1.0.1)
54
+ standard-custom (1.0.0)
55
+ lint_roller (~> 1.0)
56
+ standard-performance (1.0.1)
57
+ lint_roller (~> 1.0)
58
+ rubocop-performance (~> 1.16.0)
59
+ standardrb (1.0.1)
60
+ standard
61
+ test-unit (3.5.8)
50
62
  power_assert
63
+ unicode-display_width (2.4.2)
51
64
 
52
65
  PLATFORMS
66
+ arm64-darwin-22
53
67
  ruby
68
+ x86_64-darwin-17
54
69
 
55
70
  DEPENDENCIES
56
71
  builder
57
72
  byebug
58
73
  rake
59
74
  rspec
60
- ruby-debug
61
- ruby-debug19
75
+ standardrb
62
76
  test-unit
63
77
 
64
78
  BUNDLED WITH
65
- 1.16.1
79
+ 2.4.13
data/Markaby.gemspec CHANGED
@@ -1,24 +1,20 @@
1
- # coding: utf-8
2
- lib = File.expand_path('../lib', __FILE__)
3
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require 'markaby'
1
+ require_relative "lib/markaby/version"
5
2
 
6
3
  Gem::Specification.new do |spec|
7
- spec.name = "markaby"
8
- spec.version = Markaby::VERSION
9
- spec.authors = ["Scott Taylor", "judofyr", "_why"]
10
- spec.email = ["scott@railsnewbie.com"]
11
- spec.description = "_why's markaby templating language"
12
- spec.summary = "A pure ruby based, html markup language"
13
- spec.homepage = ""
14
- spec.license = "MIT"
4
+ spec.name = "markaby"
5
+ spec.version = Markaby::VERSION
6
+ spec.authors = ["Scott Taylor", "judofyr", "_why"]
7
+ spec.email = ["scott@railsnewbie.com"]
8
+ spec.description = "_why's markaby templating language"
9
+ spec.summary = "A pure ruby based, html markup language"
10
+ spec.homepage = ""
11
+ spec.license = "MIT"
15
12
 
16
- spec.files = `git ls-files`.split($/)
17
- spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
- spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
13
+ spec.files = `git ls-files`.split($/)
14
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
19
15
  spec.require_paths = ["lib"]
20
16
 
21
17
  spec.add_dependency "builder"
22
- spec.add_development_dependency "bundler", "~> 1.3"
18
+ spec.add_development_dependency "bundler", ">= 2.2.10"
23
19
  spec.add_development_dependency "rake"
24
20
  end
data/README.rdoc CHANGED
@@ -10,14 +10,12 @@ that blend with HTML.
10
10
  Just do what everyone else does:
11
11
 
12
12
  # in Gemfile:
13
- gem 'markaby'
13
+ gem 'markaby', '>= 0.9'
14
14
 
15
15
  then bundle install:
16
16
 
17
17
  bundle install
18
18
 
19
- or gem install if you are a weirdo not using bundler.
20
-
21
19
  === Using Markaby with Rails 4/5+:
22
20
 
23
21
  Install the gem (using bundler), then:
@@ -31,9 +29,6 @@ Install the gem (using bundler), then:
31
29
  indent: 2,
32
30
  })
33
31
 
34
- Note, Markaby hasn't been tested on anything below Rails 5. Please submit bugs
35
- and/or patches if you'd like support for anything before rails 5.
36
-
37
32
  Name your templates with an html.mab extension. You'll also want to configure
38
33
  your text editor to see .mab as ruby.
39
34
 
@@ -159,15 +154,17 @@ Which results in:
159
154
  <div class="entryContent">Okay, once again, the idea here is ...</div>
160
155
  </div>
161
156
 
157
+ Alternatively you can define the class as an attribute on your element - see below.
158
+
162
159
  == 2. Element IDs
163
160
 
164
161
  IDs may be added by the use of bang methods:
165
162
 
166
- div.page! {
167
- div.content! {
163
+ div.page! do
164
+ div.content! do
168
165
  h1 "A Short Short Saintly Dog"
169
- }
170
- }
166
+ end
167
+ end
171
168
 
172
169
  Which results in:
173
170
 
@@ -177,6 +174,8 @@ Which results in:
177
174
  </div>
178
175
  </div>
179
176
 
177
+ Alternatively you can define the ID as an attribute on your element - see below.
178
+
180
179
  == 3. Validate Your XHTML 1.0 Output
181
180
 
182
181
  If you'd like Markaby to help you assemble valid XHTML documents,
@@ -195,8 +194,8 @@ tag.
195
194
  Now, since Markaby knows which doctype you're using, it checks a big
196
195
  list of valid tags and attributes before printing anything.
197
196
 
198
- >> div :styl => "padding: 10px" do
199
- >> img :src => "samorost.jpg"
197
+ >> div styl: "padding: 10px" do
198
+ >> img src: "samorost.jpg"
200
199
  >> end
201
200
  InvalidHtmlError: no such attribute `styl'
202
201
 
@@ -222,11 +221,11 @@ as an argument:
222
221
  One caveat: if you have other tags inside a block, the string
223
222
  passed back will be ignored.
224
223
 
225
- div.comment {
224
+ div.comment do
226
225
  div.author "_why"
227
226
  div.says "Torpedoooooes!"
228
227
  "<div>Silence.</div>"
229
- }
228
+ end
230
229
 
231
230
  The final div above won't appear in the output. You can't mix
232
231
  tag modes like that, friend.
@@ -269,6 +268,8 @@ won't work with this technique.
269
268
  end
270
269
  end
271
270
 
271
+ If you wish to register your own, specialist, tags, you can install a TagHandler
272
+
272
273
  == Some other notes, so you aren't confused:
273
274
 
274
275
  === On using different tagsets:
@@ -283,6 +284,59 @@ sub-template:
283
284
  Note, this is only necessary if you were rendering, say, a one off page as
284
285
  html transitional but had the default engine as html5.
285
286
 
287
+ === Defining attributes on elements
288
+
289
+ If you do not use the <tt>CssProxy</tt> (<tt>div.entry</tt> to define the class, <tt>div.page!</tt> to define the ID), then you can pass a hash to your element to define any arbitrary attributes.
290
+
291
+ div id: "page-123", class: "entry" do
292
+ div style: "display: inline-block;" do
293
+ p "Have you noticed this book is basically written by a lunatic?"
294
+ end
295
+ end
296
+
297
+ Will result in
298
+
299
+ <div id="page-123" class="entry">
300
+ <div style="display: inline-block;">
301
+ <p>Have you noticed this book is basically written by a lunatic?</p>
302
+ </div>
303
+ </div>
304
+
305
+ If you pass a hash to your attribute definition, Markaby will expand the hash entries. This is useful for data attributes (for example, if you are using a Stimulus controller), or aria attributes. Any attributes will have underscores replaced with dashes when the hash is expanded.
306
+
307
+ div data: { controller: "something" } do
308
+ div do
309
+ h1(data: { something_target: "title" }) { "There goes my pickup" }
310
+ end
311
+ end
312
+
313
+ Will result in
314
+
315
+ <div data-controller="something">
316
+ <div>
317
+ <h1 data-something-target="title">There goes my pickup</h1>
318
+ </div>
319
+ </div>
320
+
321
+ === Custom elements and web components
322
+
323
+ If you are using the HTML5 tagset (which is the default), and your document has custom-elements defined, you can create those in the same way as standard elements.
324
+
325
+ Unlike standard elements, there is no validity checking for your attributes.
326
+
327
+ article do
328
+ my_custom_panel variant: "primary" do
329
+ p "Our careers are so over"
330
+ end
331
+ end
332
+
333
+ Results in
334
+
335
+ <article>
336
+ <my-custom-panel variant="primary">
337
+ <p>Our careers are so over</p>
338
+ </my-custom-panel>
339
+ </article>
286
340
 
287
341
  = Credits
288
342
 
data/Rakefile CHANGED
@@ -1,25 +1,25 @@
1
- require 'rake'
1
+ require "rake"
2
2
  require "bundler/gem_tasks"
3
- require 'rspec/core/rake_task'
4
- require 'rake/clean'
3
+ require "rspec/core/rake_task"
4
+ require "rake/clean"
5
5
 
6
6
  RSpec::Core::RakeTask.new(:spec)
7
- task :default => :spec
7
+ task default: :spec
8
8
 
9
9
  Bundler::GemHelper.install_tasks
10
10
 
11
11
  desc "List any Markaby specific warnings"
12
12
  task :warnings do
13
- `ruby -w test/test_markaby.rb 2>&1`.split(/\n/).each do |line|
14
- next unless line =~ /warning:/
15
- next if line =~ /builder-/
13
+ `ruby -w test/test_markaby.rb 2>&1`.split("\n").each do |line|
14
+ next unless /warning:/.match?(line)
15
+ next if /builder-/.match?(line)
16
16
  puts line
17
17
  end
18
18
  end
19
19
 
20
20
  desc "Start a Markaby-aware IRB session"
21
21
  task :irb do
22
- sh 'irb -I lib -r markaby -r markaby/kernel_method'
22
+ sh "irb -I lib -r markaby -r markaby/kernel_method"
23
23
  end
24
24
 
25
25
  namespace :gemspec do
@@ -29,19 +29,25 @@ namespace :gemspec do
29
29
  end
30
30
  end
31
31
 
32
- # namespace :release do
33
- # task :patch => [:spec, "version:bump:patch", :update_gemspec, :rerdoc, :tag_release, :build, :push_tags]
34
- #
35
- # task :update_gemspec => ["gemspec:generate", "gemspec:validate", "gemspec:commit"]
36
- # task :tag_release do
37
- # require File.dirname(__FILE__) + "/lib/markaby"
38
- # version = "v#{Markaby::VERSION}"
39
- # sh "git tag #{version}"
40
- # end
41
- #
42
- # task :push_tags do
43
- # sh "git push --tags"
44
- # end
45
- # end
46
- #
47
- # task :release => "release:patch"
32
+ namespace :release do
33
+ # make sure to bump version + update changelogs in lib/markaby/version.rb before running
34
+ task :patch => [:spec, :update_gemspec, :tag_release, :build, :push_tags]
35
+
36
+ task :update_gemspec => ["gemspec:commit"]
37
+
38
+ task :tag_release do
39
+ require File.dirname(__FILE__) + "/lib/markaby"
40
+ version = "v#{Markaby::VERSION}"
41
+ sh "git tag #{version}"
42
+ end
43
+
44
+ task :push_tags do
45
+ sh "git push --tags"
46
+ end
47
+
48
+ task :push_gem do
49
+ sh "gem push pkg/markaby-#{Markaby::VERSION}.gem"
50
+ end
51
+ end
52
+
53
+ task :release => "release:patch"
@@ -1,5 +1,5 @@
1
- require 'markaby/tags'
2
- require 'markaby/builder_tags'
1
+ require "markaby/tagset"
2
+ require "markaby/builder_tags"
3
3
 
4
4
  module Markaby
5
5
  RUBY_VERSION_ID = RUBY_VERSION.split(".").join.to_i
@@ -23,13 +23,12 @@ module Markaby
23
23
  #
24
24
  class Builder
25
25
  include Markaby::BuilderTags
26
-
27
26
  GENERIC_OPTIONS = {
28
- :indent => 0,
29
- :auto_validation => true,
27
+ indent: 0,
28
+ auto_validation: true
30
29
  }
31
30
 
32
- HTML5_OPTIONS = HTML5.default_options.dup
31
+ HTML5_OPTIONS = HTML5.default_options.dup
33
32
  DEFAULT_OPTIONS = GENERIC_OPTIONS.merge(HTML5_OPTIONS)
34
33
 
35
34
  @@options = DEFAULT_OPTIONS.dup
@@ -52,7 +51,7 @@ module Markaby
52
51
  @tagset = tagset
53
52
 
54
53
  tagset.default_options.each do |k, v|
55
- self.instance_variable_set("@#{k}".to_sym, v)
54
+ instance_variable_set("@#{k}".to_sym, v)
56
55
  end
57
56
  end
58
57
 
@@ -85,13 +84,11 @@ module Markaby
85
84
  instance_variable_set("@#{k}", v)
86
85
  end
87
86
 
88
- if helper
89
- helper.instance_variables.each do |iv|
90
- instance_variable_set(iv, helper.instance_variable_get(iv))
91
- end
87
+ helper&.instance_variables&.each do |iv|
88
+ instance_variable_set(iv, helper.instance_variable_get(iv))
92
89
  end
93
90
 
94
- @builder = XmlMarkup.new(:indent => @indent, :target => @streams.last)
91
+ @builder = XmlMarkup.new(indent: @indent, target: @streams.last)
95
92
 
96
93
  text(capture(&block)) if block
97
94
  end
@@ -150,56 +147,24 @@ module Markaby
150
147
  # Create a tag named +tag+. Other than the first argument which is the tag name,
151
148
  # the arguments are the same as the tags implemented via method_missing.
152
149
  def tag!(tag, *args, &block)
153
- ele_id = nil
154
-
155
- # TODO: Move this logic to the tagset so that the tagset itself can validate + raise when invalid
150
+ attributes = {}
156
151
  if @auto_validation && @tagset
157
- if !@tagset.tagset.has_key?(tag)
158
- raise InvalidXhtmlError, "no element `#{tag}' for #{tagset.doctype}"
159
- elsif args.last.respond_to?(:to_hash)
160
- attrs = args.last.to_hash
161
-
162
- if @tagset.forms.include?(tag) && attrs[:id]
163
- attrs[:name] ||= attrs[:id]
164
- end
165
-
166
- attrs.each do |k, v|
167
- atname = k.to_s.downcase.intern
168
-
169
- unless k =~ /:/ or @tagset.tagset[tag].include?(atname) or (@tagset == Markaby::HTML5 && atname.to_s =~ /^data-/)
170
- raise InvalidXhtmlError, "no attribute `#{k}' on #{tag} elements"
171
- end
172
-
173
- if atname == :id
174
- ele_id = v.to_s
175
-
176
- if @used_ids.has_key? ele_id
177
- raise InvalidXhtmlError, "id `#{ele_id}' already used (id's must be unique)."
178
- end
179
- end
180
-
181
- if AttrsBoolean.include? atname
182
- if v
183
- attrs[k] = atname.to_s
184
- else
185
- attrs.delete k
186
- end
187
- end
188
- end
189
- end
152
+ attributes = @tagset.validate_and_transform_attributes!(tag, *args)
153
+ tag = @tagset.validate_and_transform_tag_name! tag
190
154
  end
191
-
155
+ element_id = attributes[:id].to_s
156
+ raise InvalidXhtmlError, "id `#{element_id}' already used (id's must be unique)." if @used_ids.has_key?(element_id)
192
157
  if block
193
158
  str = capture(&block)
194
159
  block = proc { text(str) }
195
160
  end
196
161
 
197
162
  f = fragment { @builder.tag!(tag, *args, &block) }
198
- @used_ids[ele_id] = f if ele_id
163
+ @used_ids[element_id] = f unless element_id.empty?
199
164
  f
200
165
  end
201
166
 
202
- private
167
+ private
203
168
 
204
169
  # This method is used to intercept calls to helper methods and instance
205
170
  # variables. Here is the order of interception:
@@ -210,32 +175,40 @@ module Markaby
210
175
  # * If +sym+ is also the name of an instance variable, the
211
176
  # value of the instance variable is returned.
212
177
  # * If +sym+ has come this far and no +tagset+ is found, +sym+ and its arguments are passed to tag!
213
- # * If a tagset is found, though, +NoMethodError+ is raised.
178
+ # * If a tagset is found, the tagset is tole to handle +sym+
214
179
  #
215
180
  # method_missing used to be the lynchpin in Markaby, but it's no longer used to handle
216
181
  # HTML tags. See html_tag for that.
217
182
  def method_missing(sym, *args, &block)
218
- if @_helper.respond_to?(sym, true)
219
- @_helper.send(sym, *args, &block)
220
- elsif @assigns.has_key?(sym)
221
- @assigns[sym]
222
- elsif @assigns.has_key?(stringy_key = sym.to_s)
223
- # Rails' ActionView assigns hash has string keys for
224
- # instance variables that are defined in the controller.
225
- @assigns[stringy_key]
226
- elsif instance_variables_for(self).include?(ivar = "@#{sym}".to_sym)
227
- instance_variable_get(ivar)
228
- elsif @_helper && instance_variables_for(@_helper).include?(ivar)
229
- @_helper.instance_variable_get(ivar)
230
- elsif instance_methods_for(::Builder::XmlMarkup).include?(sym)
231
- @builder.__send__(sym, *args, &block)
232
- elsif !@tagset
233
- tag!(sym, *args, &block)
234
- else
235
- super
183
+ case response_for(sym)
184
+ when :helper then @_helper.send(sym, *args, &block)
185
+ when :assigns then @assigns[sym]
186
+ when :stringy_assigns then @assigns[sym.to_s]
187
+ when :ivar then instance_variable_get(ivar)
188
+ when :helper_ivar then @_helper.instance_variable_get(ivar)
189
+ when :xml_markup then @builder.__send__(sym, *args, &block)
190
+ when :tag then tag!(sym, *args, &block)
191
+ when :tagset then @tagset.handle_tag sym, self, *args, &block
192
+ else super
236
193
  end
237
194
  end
238
195
 
196
+ def response_for sym
197
+ return :helper if @_helper.respond_to?(sym, true)
198
+ return :assigns if @assigns.has_key?(sym)
199
+ return :stringy_assigns if @assigns.has_key?(sym.to_s)
200
+ return :ivar if instance_variables_for(self).include?(ivar = "@#{sym}".to_sym)
201
+ return :helper_ivar if @_helper && instance_variables_for(@_helper).include?(ivar)
202
+ return :xml_markup if instance_methods_for(::Builder::XmlMarkup).include?(sym)
203
+ return :tag if @tagset.nil?
204
+ return :tagset if @tagset.can_handle? sym
205
+ nil
206
+ end
207
+
208
+ def respond_to_missing? sym, include_private = false
209
+ !response_for(sym).nil?
210
+ end
211
+
239
212
  if RUBY_VERSION_ID >= 191
240
213
  def instance_variables_for(obj)
241
214
  obj.instance_variables
@@ -282,11 +255,15 @@ module Markaby
282
255
  undef_method method if method_defined?(method)
283
256
  end
284
257
 
285
- private
258
+ private
286
259
 
287
- def method_missing(*args, &block)
260
+ def method_missing(...)
288
261
  transform_stream unless transformed_stream?
289
- @str.__send__(*args, &block)
262
+ @str.__send__(...)
263
+ end
264
+
265
+ def respond_to_missing? sym, *args
266
+ @str.respond_to? sym
290
267
  end
291
268
 
292
269
  def transform_stream