Module: HtmlGrid::TemplateMethods
- Included in:
- DivTemplate, Template
- Defined in:
- lib/htmlgrid/template.rb
Constant Summary collapse
- CONTENT =
nil
- FOOT =
nil
- HEAD =
nil
- META_TAGS =
[]
- LEGACY_INTERFACE =
true
- CSS_FILES =
[]
- JAVASCRIPTS =
[]
Instance Method Summary collapse
- #__standard_component(model, klass) ⇒ Object
- #content(model, session = nil) ⇒ Object
- #css_link(context, path = @lookandfeel.resource(:css)) ⇒ Object
- #css_links(context, path = @lookandfeel.resource(:css)) ⇒ Object
- #dynamic_html_headers(context) ⇒ Object
- #foot(model, session = nil) ⇒ Object
- #head(model, session = nil) ⇒ Object
- #html_head(context, &block) ⇒ Object
- #javascripts(context) ⇒ Object
- #meta_tags(context) ⇒ Object
- #onload=(script) ⇒ Object
- #other_html_headers(context) ⇒ Object
- #template_html(context, &block) ⇒ Object
- #template_tags(context, &block) ⇒ Object
- #title(context) ⇒ Object
- #to_html(context) ⇒ Object
Instance Method Details
#__standard_component(model, klass) ⇒ Object
65 66 67 68 69 |
# File 'lib/htmlgrid/template.rb', line 65 def __standard_component(model, klass) if(klass.is_a?(Class)) klass.new(model, @session, self) end end |
#content(model, session = nil) ⇒ Object
53 54 55 |
# File 'lib/htmlgrid/template.rb', line 53 def content(model, session=nil) __standard_component(model, self::class::CONTENT) end |
#css_link(context, path = @lookandfeel.resource(:css)) ⇒ Object
38 39 40 41 42 43 44 45 |
# File 'lib/htmlgrid/template.rb', line 38 def css_link(context, path=@lookandfeel.resource(:css)) properties = { "rel" => "stylesheet", "type" => "text/css", "href" => path, } context.link(properties) end |
#css_links(context, path = @lookandfeel.resource(:css)) ⇒ Object
46 47 48 49 50 51 52 |
# File 'lib/htmlgrid/template.rb', line 46 def css_links(context, path=@lookandfeel.resource(:css)) links = self.class.const_get(:CSS_FILES).collect { |key| css_link(context, @lookandfeel.resource(key)) } links.push(css_link(context, path)) if(path) links.join end |
#dynamic_html_headers(context) ⇒ Object
56 57 58 |
# File 'lib/htmlgrid/template.rb', line 56 def dynamic_html_headers(context) '' end |
#foot(model, session = nil) ⇒ Object
59 60 61 |
# File 'lib/htmlgrid/template.rb', line 59 def foot(model, session=nil) __standard_component(model, self::class::FOOT) end |
#head(model, session = nil) ⇒ Object
62 63 64 |
# File 'lib/htmlgrid/template.rb', line 62 def head(model, session=nil) __standard_component(model, self::class::HEAD) end |
#html_head(context, &block) ⇒ Object
70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/htmlgrid/template.rb', line 70 def html_head(context, &block) context.head { if(block_given?) block.call end.to_s << title(context) << (context) << other_html_headers(context) << css_links(context) << javascripts(context) } end |
#javascripts(context) ⇒ Object
82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/htmlgrid/template.rb', line 82 def javascripts(context) jscripts = self.class.const_get(:JAVASCRIPTS).collect { |key| properties = { "language" => "JavaScript", "type" => "text/javascript", "src" => @lookandfeel.resource_global(:javascript, "#{key}.js"), } context.script(properties) } jscripts.join end |
#meta_tags(context) ⇒ Object
93 94 95 96 97 |
# File 'lib/htmlgrid/template.rb', line 93 def (context) self::class::META_TAGS.inject('') { |inj, properties| inj << context.(properties) } end |
#onload=(script) ⇒ Object
98 99 100 |
# File 'lib/htmlgrid/template.rb', line 98 def onload=(script) @attributes['onload'] = script end |
#other_html_headers(context) ⇒ Object
101 102 103 |
# File 'lib/htmlgrid/template.rb', line 101 def other_html_headers(context) dynamic_html_headers(context) end |
#template_html(context, &block) ⇒ Object
104 105 106 107 108 109 110 111 112 113 114 |
# File 'lib/htmlgrid/template.rb', line 104 def template_html(context, &block) args = {} if(dtd = @lookandfeel.lookup(:DOCTYPE)) args.store('DOCTYPE', dtd) end context.html(args) { html_head(context) << context.body(@attributes) { (context, &block) } } end |
#template_tags(context, &block) ⇒ Object
115 116 117 |
# File 'lib/htmlgrid/template.rb', line 115 def (context, &block) block.call end |
#title(context) ⇒ Object
118 119 120 |
# File 'lib/htmlgrid/template.rb', line 118 def title(context) context.title { @lookandfeel.lookup(:html_title) } end |
#to_html(context) ⇒ Object
121 122 123 124 125 |
# File 'lib/htmlgrid/template.rb', line 121 def to_html(context) template_html(context) { super(context) } end |