Class: Webgen::Context::HtmlHead::Proxy
- Inherits:
-
Object
- Object
- Webgen::Context::HtmlHead::Proxy
- Defined in:
- lib/webgen/context/html_head.rb
Overview
Proxy object for working with the data structure needed by Webgen::ContentProcessor::HtmlHead.
Instance Method Summary collapse
-
#initialize(context) ⇒ Proxy
constructor
:nodoc:.
-
#inline_fragment(type, content) ⇒ Object
Add inline CSS or JS fragments to the HTML head section.
-
#link_file(type, file) ⇒ Object
Add a link to the given file in the HTML head section.
-
#meta(name, content) ⇒ Object
Set the meta tag to the provided value.
-
#meta_property(name, content) ⇒ Object
Set the meta tag to the provided value, using
property
instead ofname
.
Constructor Details
#initialize(context) ⇒ Proxy
:nodoc:
15 16 17 |
# File 'lib/webgen/context/html_head.rb', line 15 def initialize(context) #:nodoc: @context = context end |
Instance Method Details
#inline_fragment(type, content) ⇒ Object
Add inline CSS or JS fragments to the HTML head section.
The type can either be :css for a CSS fragment or :js for a javascript fragment.
45 46 47 48 |
# File 'lib/webgen/context/html_head.rb', line 45 def inline_fragment(type, content) type_check!(type) (cp_hash["#{type}_inline".intern] ||= []) << content end |
#link_file(type, file) ⇒ Object
Add a link to the given file in the HTML head section.
The type can either be :css for CSS files or :js for javascript files. The path to the file is resolved using the “relocatable” tag (see Webgen::Tag::Relocatable).
37 38 39 40 |
# File 'lib/webgen/context/html_head.rb', line 37 def link_file(type, file) type_check!(type) (cp_hash["#{type}_file".intern] ||= []) << @context.tag('relocatable', file) end |
#meta(name, content) ⇒ Object
Set the meta tag to the provided value.
Note that some meta information keys may not be specified multiple times!
22 23 24 |
# File 'lib/webgen/context/html_head.rb', line 22 def (name, content) (cp_hash[:meta] ||= {})[name] = content end |
#meta_property(name, content) ⇒ Object
Set the meta tag to the provided value, using property
instead of name
.
Note that some meta information keys may not be specified multiple times!
29 30 31 |
# File 'lib/webgen/context/html_head.rb', line 29 def (name, content) (cp_hash[:meta_property] ||= {})[name] = content end |