NAME
Hub::Parse::Parser - Template parser
SYNOPSIS
use Hub qw(:standard);
my $text = 'Hello [#/user], it is [#/date/month]';
my $values = {
user => ryan,
date => {
year => 2007,
day => 10,
month => March
},
};
my $parser = mkinst('Parser', -tempate => \$text);
print $parser->parse($values);
Will produce the result:
Hello ryan, it is March
DESCRIPTION
Intention
PUBLIC METHODS
new
- Construct a new instance
-
Usage: new -template => \$text|$text, [options]
options:
-var_begin => $string # Identifies beginning of a variable (no regexp) -var_end => $string # Identifies the end of a variable (no regexp)
refresh
populate
-
Usage: populate \HASH+
Populate our template with provided variable definitions.
PARAMETERS:
\HASH Variable name to definition map
Example: (matches)
my $parser = mkinst( 'Parser', -template => 'Hello [#who]' ); ${$parser->populate( { who => 'World' } )}; Hello World
get_evaluator
- Hook into evaluator loop by overriding this method.
-
Usage: get_evaluator $directive
Returns a subroutine (CODE) reference.
This method is used by this base class to get the evaluator when a particular directive is incountered. For instance, if the template contains:
Hello Usage: get_evaluator('if') will be called. See L<Hub::Parse::StandardParser> for an example of how this class is extended.
resolve
get_hint
remove_variables
- Remove variable statements from the text
-
Usage: remove_variables \$text This will *not* remove parents of nested variables.
INTERNAL METHODS
_populate
-
Usage: _populate [OPTIONS], \HASH+
Internal worker function.
Recursive.
PARAMETERS:
\HASH Variable name to definition map
OPTIONS:
-text \SCALAR Template text to populate
_evaluate
- Evaluate the expression
-
Usage: _evaluate \@value_data, @parameters
Where @parameters are:
-fields => \@fields -outer_str => $outer_str -pos => $position -text => \$text
_to_string
_value_of - The default string value of an object
_get_block
_find_point
- Find the next occurance of a single argument directive
-
Usage: _find_point \$text, $begin_point, $directive_name, $argument_value
If you are looking for: then you would use this method as:
_find_point($text, $pos, 'parser', 'on');
_find_end_point
_padding
- Get number of preceeding and trailing whitespace characters
-
Usage: _padding \$text, $pos, $width \$text template $pos current position in $$text $width width of the current match
Returns an array of widths: ($w1, $w2)
$w1 = Number of preceeding whitespace characters $w2 = Number of trailing whitespace characters
Returns an empty array if non-whitespace characters are found in the preceeding or trailing regions.
We will look up to 80 characters in front of the current position (ie, 80 character indent maximum.)
_split_if_else
AUTHOR
Ryan Gies (ryangies@livesite.net)
COPYRIGHT
Copyright (C) 2006-2007 by Livesite Networks, LLC. All rights reserved.
Copyright (C) 2000-2005 by Ryan Gies. All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
* The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
* Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
* The name of the author may not be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
To the best of our knowledge, no patented algorithms have been used. However, we do not have the resources to carry out a patent search, and therefore cannot give any guarantee of the above statement.
UPDATED
06/09/2007
1 POD Error
The following errors were encountered while parsing the POD:
- Around line 121:
=back doesn't take any parameters, but you said =back =head2 get_value