Class: Sinatra::Exstatic::Tag

Inherits:
String
  • Object
show all
Defined in:
lib/sinatra/exstatic_assets.rb

Overview

For creating HTML tags.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, options = {}, &block) ⇒ Tag

Returns a new instance of Tag.

Examples:

Tag.new "img", {src: "/images/foo.jpg", width: "500"}
# => "<img src="/images/foo.jpg" width="500" />"

Parameters:

  • name (String)

    The tag name e.g. ‘link`.

  • options (Hash) (defaults to: {})

    With the exception of any options listed here, these are passed to the tag to make the HTML attributes.

  • block (#call)

    The contents of the block are wrapped by the HTML tag e.g. <p>This is from the block</p>

Options Hash (options):

  • :closed (TrueClass)

    Whether to self-close the link XHTML style or not.



19
20
21
22
23
24
25
26
# File 'lib/sinatra/exstatic_assets.rb', line 19

def initialize( name, options={}, &block )
  @name       = name
  @closed = (c = options.delete(:closed)).nil? ? true : c
  @options    = options
  @attributes = self.class.make_attributes @options
  @block      = block
  super tag
end

Instance Attribute Details

#attributesObject (readonly)

Returns the value of attribute attributes.



28
29
30
# File 'lib/sinatra/exstatic_assets.rb', line 28

def attributes
  @attributes
end

#nameObject (readonly)

Returns the value of attribute name.



28
29
30
# File 'lib/sinatra/exstatic_assets.rb', line 28

def name
  @name
end

#optionsObject (readonly)

Returns the value of attribute options.



28
29
30
# File 'lib/sinatra/exstatic_assets.rb', line 28

def options
  @options
end