module HtmlGrid::TemplateMethods
Constants
- CONTENT
- CSS_FILES
- FOOT
- HEAD
- JAVASCRIPTS
- LEGACY_INTERFACE
- META_TAGS
Public Class Methods
get_inline(ressource)
click to toggle source
# File lib/htmlgrid/template.rb, line 40 def self.get_inline(ressource) return nil unless ressource local_file = File.join(@@local_doc_dir, URI(ressource).path) File.exist?(local_file) ? File.read(local_file) : nil end
Public Instance Methods
__standard_component(model, klass)
click to toggle source
# File lib/htmlgrid/template.rb, line 85 def __standard_component(model, klass) if klass.is_a?(Class) klass.new(model, @session, self) end end
content(model, session = nil)
click to toggle source
# File lib/htmlgrid/template.rb, line 69 def content(model, session = nil) __standard_component(model, self.class::CONTENT) end
css_link(context, path = @lookandfeel.resource(:css))
click to toggle source
# File lib/htmlgrid/template.rb, line 46 def css_link(context, path = @lookandfeel.resource(:css)) properties = { "rel" => "stylesheet", "type" => "text/css", "async" => "true", "href" => path } if (content = TemplateMethods.get_inline(path)) properties.delete("href") context.style(properties) { content } else context.link(properties) end end
css_links(context, path = @lookandfeel.resource(:css))
click to toggle source
# File lib/htmlgrid/template.rb, line 61 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)
click to toggle source
# File lib/htmlgrid/template.rb, line 73 def dynamic_html_headers(context) "" end
foot(model, session = nil)
click to toggle source
# File lib/htmlgrid/template.rb, line 77 def foot(model, session = nil) __standard_component(model, self.class::FOOT) end
head(model, session = nil)
click to toggle source
# File lib/htmlgrid/template.rb, line 81 def head(model, session = nil) __standard_component(model, self.class::HEAD) end
html_head(context, &block)
click to toggle source
# File lib/htmlgrid/template.rb, line 91 def html_head(context, &block) context.head { block&.call context.head << title(context) << meta_tags(context) << other_html_headers(context) << css_links(context) << javascripts(context) } end
javascripts(context)
click to toggle source
# File lib/htmlgrid/template.rb, line 102 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
onload=(script)
click to toggle source
# File lib/htmlgrid/template.rb, line 120 def onload=(script) @attributes["onload"] = script end
other_html_headers(context)
click to toggle source
# File lib/htmlgrid/template.rb, line 124 def other_html_headers(context) dynamic_html_headers(context) end
template_html(context, &block)
click to toggle source
# File lib/htmlgrid/template.rb, line 128 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) { template_tags(context, &block) } } end
title(context)
click to toggle source
# File lib/htmlgrid/template.rb, line 144 def title(context) context.title { @lookandfeel.lookup(:html_title) } end
to_html(context)
click to toggle source
Calls superclass method
# File lib/htmlgrid/template.rb, line 148 def to_html(context) template_html(context) { super(context) } end