module Markaby::BuilderTags

Public Instance Methods

enable_html5!() click to toggle source
# File lib/markaby/builder_tags.rb, line 63
def enable_html5!
  self.tagset = Markaby::HTML5

  Markaby::Builder::HTML5_OPTIONS.each do |k, v|
    self.instance_variable_set("@#{k}".to_sym, v)
  end
end
head(*args, &block) click to toggle source

Builds a head tag. Adds a meta tag inside with Content-Type set to text/html; charset=utf-8.

# File lib/markaby/builder_tags.rb, line 29
def head(*args, &block)
  tag!(:head, *args) do
    tag!(:meta, "http-equiv" => "Content-Type", "content" => "text/html; charset=utf-8") if @output_meta_tag == 'xhtml'
    tag!(:meta, "charset" => "utf-8") if @output_meta_tag == 'html5'
    instance_eval(&block)
  end
end
html5(attrs = {}, &block) click to toggle source

Builds an html tag with HTML5 doctype instead.

# File lib/markaby/builder_tags.rb, line 58
def html5(attrs = {}, &block)
  enable_html5!
  html5_html(attrs, &block)
end
html_tag(sym, *args, &block) click to toggle source

Every HTML tag method goes through an #html_tag call. So, calling div is equivalent to calling html_tag(:div). All HTML tags in Markaby's list are given generated wrappers for this method.

If the @auto_validation setting is on, this method will check for many common mistakes which could lead to invalid XHTML.

# File lib/markaby/builder_tags.rb, line 17
def html_tag(sym, *args, &block)
  if @auto_validation && @tagset.self_closing.include?(sym) && block
    raise InvalidXhtmlError, "the `#{sym}' element is self-closing, please remove the block"
  elsif args.empty? && !block
    CssProxy.new(self, @streams.last, sym)
  else
    tag!(sym, *args, &block)
  end
end
xhtml_frameset(attrs = {}, &block) click to toggle source

Builds an html tag with XHTML 1.0 Frameset doctype instead.

# File lib/markaby/builder_tags.rb, line 52
def xhtml_frameset(attrs = {}, &block)
  self.tagset = Markaby::XHTMLFrameset
  xhtml_html(attrs, &block)
end
xhtml_strict(attrs = {}, &block) click to toggle source

Builds an html tag with XHTML 1.0 Strict doctype instead.

# File lib/markaby/builder_tags.rb, line 46
def xhtml_strict(attrs = {}, &block)
  self.tagset = Markaby::XHTMLStrict
  xhtml_html(attrs, &block)
end
xhtml_transitional(attrs = {}, &block) click to toggle source

Builds an html tag. An XML 1.0 instruction and an XHTML 1.0 Transitional doctype are prepended. Also assumes :xmlns => "http://www.w3.org/1999/xhtml", :lang => "en".

# File lib/markaby/builder_tags.rb, line 40
def xhtml_transitional(attrs = {}, &block)
  self.tagset = Markaby::XHTMLTransitional
  xhtml_html(attrs, &block)
end

Private Instance Methods

html5_html(attrs = {}, &block) click to toggle source
# File lib/markaby/builder_tags.rb, line 79
def html5_html(attrs = {}, &block)
  declare!(:DOCTYPE, :html)
  tag!(:html, @root_attributes.merge(attrs), &block)
end
xhtml_html(attrs = {}, &block) click to toggle source
# File lib/markaby/builder_tags.rb, line 73
def xhtml_html(attrs = {}, &block)
  instruct! if @output_xml_instruction
  declare!(:DOCTYPE, :html, :PUBLIC, *tagset.doctype)
  tag!(:html, @root_attributes.merge(attrs), &block)
end