Class: Inversion::Template::ConfigTag
- Includes:
- HashUtilities
- Defined in:
- lib/inversion/template/configtag.rb
Overview
Inversion ‘config’ tag.
A tag that dynamically alters the behavior of the template.
Examples
<?config comment_start: /* ?>
<?config comment_end: */ ?>
<?config
on_render_error: propagate
debugging_comments: true
comment_start: /*
comment_end: */
?>
<?config { comment_start: "/*", comment_end: "*/" } ?>
Constant Summary
Constants inherited from Tag
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
The config options that will be modified.
Attributes inherited from Tag
Attributes inherited from Node
Instance Method Summary collapse
-
#before_appending(parsestate) ⇒ Object
Override the options in the ‘parsestate` when the config is appended to the tree.
-
#before_rendering(renderstate) ⇒ Object
Override the options in the ‘renderstate` when the config is rendered.
-
#initialize(body, linenum = nil, colnum = nil) ⇒ ConfigTag
constructor
Create a new ConfigTag with the specified ‘body`.
Methods included from HashUtilities
stringify_keys, symbolify_keys
Methods inherited from Tag
#as_comment_body, create, #derivatives, inherited, load, load_all, #tagname, types, #types
Methods included from MethodUtilities
#singleton_attr_accessor, #singleton_attr_reader, #singleton_attr_writer
Methods included from AbstractClass
Methods included from AbstractClass::ClassMethods
Methods inherited from Node
#after_appending, #after_rendering, #as_comment_body, #is_container?, #location, #render
Constructor Details
#initialize(body, linenum = nil, colnum = nil) ⇒ ConfigTag
Create a new ConfigTag with the specified ‘body`.
35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/inversion/template/configtag.rb', line 35 def initialize( body, linenum=nil, colnum=nil ) raise Inversion::ParseError, 'Empty config settings' if body.nil? || body.strip.empty? opts = if defined?( SafeYAML ) then YAML.load( body, safe: true ) else YAML.load( body ) end @options = symbolify_keys( opts ) super end |
Instance Attribute Details
#options ⇒ Object (readonly)
The config options that will be modified
56 57 58 |
# File 'lib/inversion/template/configtag.rb', line 56 def @options end |
Instance Method Details
#before_appending(parsestate) ⇒ Object
Override the options in the ‘parsestate` when the config is appended to the tree.
61 62 63 |
# File 'lib/inversion/template/configtag.rb', line 61 def before_appending( parsestate ) parsestate..merge!( self. ) end |
#before_rendering(renderstate) ⇒ Object
Override the options in the ‘renderstate` when the config is rendered.
67 68 69 |
# File 'lib/inversion/template/configtag.rb', line 67 def before_rendering( renderstate ) renderstate..merge!( self. ) end |