Class: Arrow::Template::SetDirective
- Defined in:
- lib/arrow/template/set.rb
Overview
The Arrow::Template::SetDirective class, a derivative of Arrow::Template::Directive. This is the class which defines the behaviour of the ‘set’ template directive.
Syntax
<?set foo 1?>
Authors
-
Michael Granger <[email protected]>
Please see the file LICENSE in the top-level directory for licensing details.
Constant Summary collapse
- SVNRev =
SVN Revision
%q$Rev$
- SVNId =
SVN Id
%q$Id$
Constants included from HTMLUtilities
HTMLUtilities::ARRAY_HTML_CONTAINER, HTMLUtilities::HASH_HTML_CONTAINER, HTMLUtilities::HASH_PAIR_HTML, HTMLUtilities::IMMEDIATE_OBJECT_HTML_CONTAINER, HTMLUtilities::IVAR_HTML_FRAGMENT, HTMLUtilities::OBJECT_HTML_CONTAINER, HTMLUtilities::THREAD_DUMP_KEY
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
The name of the definition set by this directive.
-
#value ⇒ Object
readonly
The raw (unevaluated) value of the definition.
Attributes inherited from Node
Instance Method Summary collapse
-
#initialize(type, parser, state) ⇒ SetDirective
constructor
Create and return a new Arrow::Template::SetDirective object.
-
#render(template, scope) ⇒ Object
Render the directive.
Methods inherited from Directive
create, derivativeDirs, #inspect, #to_html
Methods inherited from Node
#add_to_template, #inspect, #is_rendering_node?, #to_a, #to_html, #to_s
Methods included from HTMLUtilities
escape_html, make_html_for_object, make_object_html_wrapper
Methods inherited from Object
deprecate_class_method, deprecate_method, inherited
Constructor Details
#initialize(type, parser, state) ⇒ SetDirective
Create and return a new Arrow::Template::SetDirective object.
29 30 31 32 33 34 |
# File 'lib/arrow/template/set.rb', line 29 def initialize( type, parser, state ) @name = nil @value = nil super end |
Instance Attribute Details
#name ⇒ Object (readonly)
The name of the definition set by this directive.
42 43 44 |
# File 'lib/arrow/template/set.rb', line 42 def name @name end |
#value ⇒ Object (readonly)
The raw (unevaluated) value of the definition
45 46 47 |
# File 'lib/arrow/template/set.rb', line 45 def value @value end |
Instance Method Details
#render(template, scope) ⇒ Object
Render the directive. This adds the defined variable to the template
‘s rendering scope
and returns an empty string (or a comment if :debuggingComments
is turned on in the template.
51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/arrow/template/set.rb', line 51 def render( template, scope ) rval = super self.log.debug "Evaling <%s> for 'set' directive." % @value template[@name] = eval( @value, scope.get_binding, __FILE__, __LINE__ ) if template._config[:debuggingComments] rval << template.render_comment( "Set '%s' to '%s'" % [ @name, template[@name] ] ) end return rval end |