Class: Arrow::Template::ImportDirective
- Includes:
- Parser::Patterns
- Defined in:
- lib/arrow/template/import.rb
Overview
The Arrow::Template::ImportDirective class, a derivative of Arrow::Template::Directive. This is the class which defines the behaviour of the ‘import’ template directive.
Syntax
<?import foo?>
<?import foo as superfoo?>
<?import foo, bar?> <?import foo as superfoo, bar, baz as bazish?>
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$
- SIMPLEIMPORT =
Various patterns
CAPTURE[ IDENTIFIER ]
- ALIASIMPORT =
CAPTURE[ IDENTIFIER ] + /\s+as\s+/i + CAPTURE[ IDENTIFIER ]
Constants included from Parser::Patterns
Parser::Patterns::ALTERNATION, Parser::Patterns::ARGDEFAULT, Parser::Patterns::ARGUMENT, Parser::Patterns::CAPTURE, Parser::Patterns::COMMA, Parser::Patterns::DBLQSTRING, Parser::Patterns::DOT, Parser::Patterns::EQUALS, Parser::Patterns::IDENTIFIER, Parser::Patterns::INFIX, Parser::Patterns::LBRACKET, Parser::Patterns::NUMBER, Parser::Patterns::PATHNAME, Parser::Patterns::QUOTEDSTRING, Parser::Patterns::RBRACKET, Parser::Patterns::REBINDOP, Parser::Patterns::REGEXP, Parser::Patterns::SLASHQSTRING, Parser::Patterns::SYMBOL, Parser::Patterns::TAGCLOSE, Parser::Patterns::TAGMIDDLE, Parser::Patterns::TAGOPEN, Parser::Patterns::TICKQSTRING, Parser::Patterns::VARIABLE, Parser::Patterns::WHITESPACE
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
-
#patterns ⇒ Object
readonly
An Array of Regexp objects which match the names of attributes to be imported.
Attributes inherited from Node
Class Method Summary collapse
-
.allows_format? ⇒ Boolean
Disallow formats.
Instance Method Summary collapse
-
#initialize(type, parser, state) ⇒ ImportDirective
constructor
Create a new ImportDirective object.
-
#render(template, scope) ⇒ Object
Add the imported attributes when this node is rendered.
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) ⇒ ImportDirective
Create a new ImportDirective object.
50 51 52 53 |
# File 'lib/arrow/template/import.rb', line 50 def initialize( type, parser, state ) @imports = {} super end |
Instance Attribute Details
#patterns ⇒ Object (readonly)
An Array of Regexp objects which match the names of attributes to be imported.
62 63 64 |
# File 'lib/arrow/template/import.rb', line 62 def patterns @patterns end |
Class Method Details
.allows_format? ⇒ Boolean
Disallow formats
42 |
# File 'lib/arrow/template/import.rb', line 42 def self::allows_format?; false; end |
Instance Method Details
#render(template, scope) ⇒ Object
Add the imported attributes when this node is rendered.
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/arrow/template/import.rb', line 66 def render( template, scope ) imports = [] if (( st = template._enclosing_template )) @imports.each do |source,dest| imports << "%s as %s (%p)" % [ source, dest, st._attributes[source] ] template._attributes[dest] = st._attributes[source] end end if template._config[:debuggingComments] return template.render_comment( "Importing: " + imports.join(", ") ) else return '' end end |