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
permalink #initialize(body, linenum = nil, colnum = nil) ⇒ ConfigTag
Create a new ConfigTag with the specified body
.
36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/inversion/template/configtag.rb', line 36 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
permalink #options ⇒ Object (readonly)
The config options that will be modified
57 58 59 |
# File 'lib/inversion/template/configtag.rb', line 57 def @options end |
Instance Method Details
permalink #before_appending(parsestate) ⇒ Object
Override the options in the parsestate
when the config is appended to the tree.
62 63 64 |
# File 'lib/inversion/template/configtag.rb', line 62 def before_appending( parsestate ) parsestate..merge!( self. ) end |
permalink #before_rendering(renderstate) ⇒ Object
Override the options in the renderstate
when the config is rendered.
68 69 70 |
# File 'lib/inversion/template/configtag.rb', line 68 def before_rendering( renderstate ) renderstate..merge!( self. ) end |