Inversion::Template::

ConfigTag class

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: "*/" } ?>

Attributes

options R

The config options that will be modified

Public Class Methods

new( body, linenum=nil, colnum=nil )

Create a new ConfigTag with the specified ‘body`.

# File lib/inversion/template/configtag.rb, line 34
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

Public Instance Methods

before_appending( parsestate )

Override the options in the ‘parsestate` when the config is appended to the tree.

# File lib/inversion/template/configtag.rb, line 60
def before_appending( parsestate )
        parsestate.options.merge!( self.options )
end
before_rendering( renderstate )

Override the options in the ‘renderstate` when the config is rendered.

# File lib/inversion/template/configtag.rb, line 66
def before_rendering( renderstate )
        renderstate.options.merge!( self.options )
end