Class: Arbre::Html::Document
- Defined in:
- lib/arbre/html/document.rb
Overview
Root tag for any Html document.
Represents the combination of a doctype, a head
tag and a body
tag.
Direct Known Subclasses
Instance Attribute Summary
Attributes inherited from Tag
Instance Method Summary collapse
-
#body(&block) ⇒ Object
Adds content to the body tag and/or returns it.
-
#build! ⇒ Object
Building.
- #doctype ⇒ Object
-
#head(&block) ⇒ Object
Adds content to the head tag and/or returns it.
-
#initialize ⇒ Document
constructor
Initialization.
-
#tag_name ⇒ Object
Rendering.
-
#title ⇒ Object
Head & body accessors.
- #title=(title) ⇒ Object
- #to_s ⇒ Object
Methods inherited from Tag
#[], #[]=, #add_class, attribute, #classes, classes, #classes=, #empty?, #generate_id!, #has_attribute?, #has_class?, id, #inspect, #one_line?, #remove_class, #self_closing_tag?, #style, #style=, tag, #tag_classes, #tag_id
Methods inherited from Element
#+, #<<, #ancestors, #arbre_context, #assigns, #children, #content, #content=, #descendants, #empty?, #has_children?, #helpers, #indent_level, #inspect, #orphan?, #parent, #parent=, #remove!, #respond_to?, #to_html
Methods included from Querying
#child_tags, #descendant_tags, #find, #find_by_classes, #find_by_id, #find_by_tag, #find_by_tag_and_classes, #find_first
Methods included from Element::Building
#append_within, #append_within?, #build, #current_element, #current_flow, included, #insert, #insert_child, #prepend_within, #prepend_within?, #temporary
Constructor Details
#initialize ⇒ Document
Initialization
12 13 14 |
# File 'lib/arbre/html/document.rb', line 12 def initialize(*) super end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Arbre::Element
Instance Method Details
#body(&block) ⇒ Object
Adds content to the body tag and/or returns it.
67 68 69 70 |
# File 'lib/arbre/html/document.rb', line 67 def body(&block) within @_body, &block if block_given? @_body end |
#build! ⇒ Object
Building
19 20 21 22 23 24 25 26 |
# File 'lib/arbre/html/document.rb', line 19 def build! append_head append_body within body do yield self if block_given? end end |
#doctype ⇒ Object
79 80 81 |
# File 'lib/arbre/html/document.rb', line 79 def doctype '<!DOCTYPE html>'.html_safe end |
#head(&block) ⇒ Object
Adds content to the head tag and/or returns it.
61 62 63 64 |
# File 'lib/arbre/html/document.rb', line 61 def head(&block) within @_head, &block if block_given? @_head end |
#tag_name ⇒ Object
Rendering
75 76 77 |
# File 'lib/arbre/html/document.rb', line 75 def tag_name 'html' end |
#title ⇒ Object
Head & body accessors
47 48 49 |
# File 'lib/arbre/html/document.rb', line 47 def title @title ||= title_tag.content end |
#title=(title) ⇒ Object
51 52 53 |
# File 'lib/arbre/html/document.rb', line 51 def title=(title) @title = title_tag.content = title end |
#to_s ⇒ Object
83 84 85 86 87 88 |
# File 'lib/arbre/html/document.rb', line 83 def to_s out = ActiveSupport::SafeBuffer.new out << doctype out << "\n\n" out << super end |