Module: Markaby::BuilderTags
- Included in:
- Builder
- Defined in:
- lib/markaby/builder_tags.rb
Instance Method Summary collapse
- #enable_html5! ⇒ Object
-
#head(*args, &block) ⇒ Object
Builds a head tag.
-
#html5(attrs = {}, &block) ⇒ Object
Builds an html tag with HTML5 doctype instead.
-
#html_tag(sym, *args, &block) ⇒ Object
Every HTML tag method goes through an html_tag call.
-
#xhtml_frameset(attrs = {}, &block) ⇒ Object
Builds an html tag with XHTML 1.0 Frameset doctype instead.
-
#xhtml_strict(attrs = {}, &block) ⇒ Object
Builds an html tag with XHTML 1.0 Strict doctype instead.
-
#xhtml_transitional(attrs = {}, &block) ⇒ Object
Builds an html tag.
Instance Method Details
#enable_html5! ⇒ Object
65 66 67 |
# File 'lib/markaby/builder_tags.rb', line 65 def enable_html5! raise NotImplementedError, "Deprecated! Call self.tagset = Markaby::HTML5" end |
#head(*args, &block) ⇒ Object
Builds a head tag. Adds a meta
tag inside with Content-Type set to text/html; charset=utf-8
.
31 32 33 34 35 36 37 |
# File 'lib/markaby/builder_tags.rb', line 31 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) ⇒ Object
Builds an html tag with HTML5 doctype instead.
60 61 62 63 |
# File 'lib/markaby/builder_tags.rb', line 60 def html5(attrs = {}, &block) self. = Markaby::HTML5 html5_html(attrs, &block) end |
#html_tag(sym, *args, &block) ⇒ Object
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.
19 20 21 22 23 24 25 26 27 |
# File 'lib/markaby/builder_tags.rb', line 19 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) ⇒ Object
Builds an html tag with XHTML 1.0 Frameset doctype instead.
54 55 56 57 |
# File 'lib/markaby/builder_tags.rb', line 54 def xhtml_frameset(attrs = {}, &block) self. = Markaby::XHTMLFrameset xhtml_html(attrs, &block) end |
#xhtml_strict(attrs = {}, &block) ⇒ Object
Builds an html tag with XHTML 1.0 Strict doctype instead.
48 49 50 51 |
# File 'lib/markaby/builder_tags.rb', line 48 def xhtml_strict(attrs = {}, &block) self. = Markaby::XHTMLStrict xhtml_html(attrs, &block) end |
#xhtml_transitional(attrs = {}, &block) ⇒ Object
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"
.
42 43 44 45 |
# File 'lib/markaby/builder_tags.rb', line 42 def xhtml_transitional(attrs = {}, &block) self. = Markaby::XHTMLTransitional xhtml_html(attrs, &block) end |