Class: Arrow::Template::SelectListDirective
- Inherits:
-
BracketingDirective
- Object
- Arrow::Object
- Node
- Directive
- AttributeDirective
- BracketingDirective
- Arrow::Template::SelectListDirective
- Includes:
- Parser::Patterns
- Defined in:
- lib/arrow/template/selectlist.rb
Overview
The Arrow::Template::SelectListDirective class, a derivative of Arrow::Template::AttributeDirective. This is the class which defines the behaviour of the ‘selectlist’ template directive.
Syntax
<?selectlist categories ?><?end?> <?selectlist category FROM categories ?><?end?> <?selectlist category FROM categories.sort_by {|c| c.name } ?><?end?>
VCS Id
$Id$
Authors
Michael Granger
Please see the file LICENSE in the top-level directory for licensing details.
Constant Summary
- SVNRev =
SVN Revision
%q$Rev$
- SVNId =
SVN Id
%q$Id$
- NAMEDLIST =
CAPTURE[ IDENTIFIER ] + /\s+from\s+/i
Constants included from Parser::Patterns
ALTERNATION, ARGDEFAULT, ARGUMENT, CAPTURE, COMMA, DBLQSTRING, DOT, EQUALS, IDENTIFIER, INFIX, LBRACKET, NUMBER, PATHNAME, QUOTEDSTRING, RBRACKET, REBINDOP, REGEXP, SLASHQSTRING, SYMBOL, TAGCLOSE, TAGMIDDLE, TAGOPEN, TICKQSTRING, VARIABLE, WHITESPACE
Constants inherited from BracketingDirective
Constants inherited from AttributeDirective
Constants inherited from Directive
Constants inherited from Node
Constants included from Arrow::HTMLUtilities
ARRAY_HTML_CONTAINER, HASH_HTML_CONTAINER, HASH_PAIR_HTML, IMMEDIATE_OBJECT_HTML_CONTAINER, IVAR_HTML_FRAGMENT, OBJECT_HTML_CONTAINER, THREAD_DUMP_KEY
Instance Attribute Summary
- - (Object) select_name readonly
Class Method Summary
-
+ (Boolean) allows_format?
This directive doesn’t allow formatting.
Instance Method Summary
-
- (SelectListDirective) initialize(body, parser, state)
constructor
Create a new Arrow::Template::SelectListDirective object.
-
- (Object) parse_directive_contents(parser, state)
protected
Parse the contents of the directive.
-
- (Object) render_subnodes(attribute, template, scope)
protected
Render the directive’s bracketed nodes once for each item in the iterated content.
Methods inherited from BracketingDirective
#add_to_template, #inspect, #is_rendering_node?, #render_contents, #to_a, #to_html
Methods inherited from AttributeDirective
#before_rendering, #build_rendering_proc, #call_methodchain, #inspect, #is_rendering_node?, #render, #render_contents, #to_html
Methods inherited from Directive
create, derivativeDirs, #inspect, #render, #to_html
Methods inherited from Node
#add_to_template, #css_class, #inspect, #is_rendering_node?, #render, #to_a, #to_html, #to_s
Methods included from Arrow::HTMLUtilities
#escape_html, #make_html_for_object, #make_object_html_wrapper
Methods inherited from Arrow::Object
deprecate_class_method, deprecate_method, inherited
Methods included from Arrow::Loggable
Constructor Details
- (SelectListDirective) initialize(body, parser, state)
Create a new Arrow::Template::SelectListDirective object.
46 47 48 49 |
# File 'lib/arrow/template/selectlist.rb', line 46 def initialize( body, parser, state ) @select_name = nil super end |
Instance Attribute Details
- (Object) select_name (readonly)
56 57 58 |
# File 'lib/arrow/template/selectlist.rb', line 56 def select_name @select_name end |
Class Method Details
+ (Boolean) allows_format?
This directive doesn’t allow formatting.
40 41 42 |
# File 'lib/arrow/template/selectlist.rb', line 40 def self::allows_format? false end |
Instance Method Details
- (Object) parse_directive_contents(parser, state) (protected)
Parse the contents of the directive
65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/arrow/template/selectlist.rb', line 65 def parse_directive_contents( parser, state ) state.scanner.skip( WHITESPACE ) if state.scanner.scan( NAMEDLIST ) @select_name = state.scanner[1] end super return true end |
- (Object) render_subnodes(attribute, template, scope) (protected)
Render the directive’s bracketed nodes once for each item in the iterated content.
80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/arrow/template/selectlist.rb', line 80 def render_subnodes( attribute, template, scope ) res = [] res << %{<select name="%s">\n} % [ self.select_name || self.name ] attribute.each do |attrib| res << %{ <option value="%s">%s</option>\n} % [ attrib, attrib ] end res << %{</select>\n} return *res end |