Class: HammerBuilder::StubBuilderForDocumentation::AbstractDoubleTag
- Inherits:
-
AbstractTag
- Object
- AbstractTag
- HammerBuilder::StubBuilderForDocumentation::AbstractDoubleTag
- Defined in:
- lib/hammer_builder/doc.rb
Constant Summary
Constants inherited from AbstractTag
HammerBuilder::StubBuilderForDocumentation::AbstractTag::METHOD_MISSING_REGEXP
Instance Attribute Summary
Attributes inherited from AbstractTag
Instance Method Summary collapse
- #attribute(name, value, &block) ⇒ Object
- #attributes(attrs, &block) ⇒ Object
-
#content(content) ⇒ Object
sets content of the double tag.
- #data(hash, &block) ⇒ Object
-
#flush ⇒ Object
private
closes the tag.
-
#initialize(builder) ⇒ AbstractDoubleTag
constructor
private
A new instance of AbstractDoubleTag.
-
#method_missing(method, *args, &block) ⇒ Object
allows data-* attributes and id, classes by method_missing.
- #mimic(obj, &block) ⇒ Object
- #open(*args, &block) ⇒ Object private
-
#with { ... } ⇒ Object
(also: #w)
renders content of the double tag with block.
Methods inherited from AbstractTag
attributes, #class, #id, #rclass, strings_injector, tag_name
Constructor Details
#initialize(builder) ⇒ AbstractDoubleTag
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of AbstractDoubleTag.
250 251 252 253 |
# File 'lib/hammer_builder/doc.rb', line 250 def initialize(builder) super @content = nil end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Object
allows data-* attributes and id, classes by method_missing
256 257 258 259 260 261 262 263 264 265 266 267 268 269 |
# File 'lib/hammer_builder/doc.rb', line 256 def method_missing(method, *args, &block) method = method.to_s if method =~ METHOD_MISSING_REGEXP if $1 self.rclass.add_attributes Data::Attribute.new(method.to_sym, :string) self.send method, *args, &block else self.content(args[0]) if args[0] self.__send__($3 == '!' ? :id : :class, $2, &block) end else super(method, *args, &block) end end |
Instance Method Details
#attribute(name, value, &block) ⇒ Object
341 342 343 344 345 |
# File 'lib/hammer_builder/doc.rb', line 341 def attribute(name, value, &block) super(name, value, &nil) return with(&block) if block self end |
#attributes(attrs, &block) ⇒ Object
347 348 349 350 351 |
# File 'lib/hammer_builder/doc.rb', line 347 def attributes(attrs, &block) super(attrs, &nil) return with(&block) if block self end |
#content(content) ⇒ Object
sets content of the double tag
301 302 303 304 |
# File 'lib/hammer_builder/doc.rb', line 301 def content(content) @content = content.to_s self end |
#data(hash, &block) ⇒ Object
335 336 337 338 339 |
# File 'lib/hammer_builder/doc.rb', line 335 def data(hash, &block) super(hash, &nil) return with(&block) if block self end |
#flush ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
closes the tag
288 289 290 291 292 293 294 |
# File 'lib/hammer_builder/doc.rb', line 288 def flush flush_classes @output << @_str_gt @output << CGI.escapeHTML(@content) if @content @output << @_str_slash_lt << @stack.pop << @_str_gt @content = nil end |
#mimic(obj, &block) ⇒ Object
329 330 331 332 333 |
# File 'lib/hammer_builder/doc.rb', line 329 def mimic(obj, &block) super(obj, &nil) return with(&block) if block self end |
#open(*args, &block) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
272 273 274 275 276 277 278 279 280 281 282 283 284 |
# File 'lib/hammer_builder/doc.rb', line 272 def open(*args, &block) attributes = if args.last.is_a?(Hash) args.pop end content args[0] super attributes @stack << @tag_name if block with &block else self end end |
#with { ... } ⇒ Object Also known as: w
renders content of the double tag with block
313 314 315 316 317 318 319 320 321 322 323 324 325 |
# File 'lib/hammer_builder/doc.rb', line 313 def with flush_classes @output << @_str_gt @content = nil @builder.current = nil yield #if (content = yield).is_a?(String) # @output << EscapeUtils.escape_html(content) #end @builder.flush @output << @_str_slash_lt << @stack.pop << @_str_gt nil end |