NAME
Modwheel::Template::Shortcuts.
Class for expanding shortcut abbreviations in strings.
VERSION
v0.2.2
SYNOPSIS
my $string = '[http:www.google.com|Gooooogle]';
my $shortcuts = Modwheel::Template::Shortcuts->new({
modwheel => $modwheel,
template => $template,
);
$string = $shortcuts->parse($string);
print $string, "\n";
# string is now: '<a href="http://www.google.com">Gooooogle</a>'
# with the default modwheel configuration.
DESCRIPTION
In the Modwheel configuration file you can define a set of shortcuts. An example of an abbreviation with the name CPAN, could be defined like this:
shortcuts:
cpan: <a href="http://search.cpan.org?query=[:content]">[name]</a>
Now, if you have a string that contains [cpan:Carp|The Carp Module]
and send it to $shortcuts->parse
it will replace it with <a href="http://search.cpan.org?query=Carp">The Carp Module</a>
The syntax for resolving an abbreviation in text is: [type:content|name]
The type is the name of the shortcut in the configuration file.
<a href="http://search.cpan.org?query=
[:content] -> Carp
">
[name] -> The Carp Module
If you add a : (colon) to a variable in the shortcut configuration, the characthers will be properly escaped by using URI::Escape.
SUBROUTINES/METHODS
CONSTRUCTOR
INSTANCE METHODS
PRIVATE ATTRIBUTES
$shortcuts->template($template)
=item$shortcuts->set_template($template)
-
Set or get the Modwheel template object.
$shortcuts->resolvers($resolvers)
=item$shortcuts->set_resolvers($resolvers)
-
Set or get the current resolvers hash.
PRIVATE INSTANCE METHODS
$shortcuts->init_resolvers()
-
Initialize the resolvers hash using the modwheel configuration file. Used by new().
$shortcuts->resolve($string)
-
Private function used by
parse()
to resolve the shortcuts. $shortcuts->_uri_escape($string)
-
Uses URI::Escape to properly escape unsafe carachters in a string to be used as an URI.
DIAGNOSTICS
If the [file:] type does not work:
Remember that the file type needs access to the Repository object. Are you sure you passed the repository object when calling
->new()
?
CONFIGURATION AND ENVIRONMENT
Uses the Modwheel configuration file. config/modwheelconfig.yml
See Modwheel::Manual::Config for more information.
DEPENDENCIES
INCOMPATIBILITIES
None known.
BUGS AND LIMITATIONS
None known.
SEE ALSO
-
The Modwheel manual.
http://www.0x61736b.net/Modwheel/
The Modwheel website.
AUTHOR
Ask Solem, ask@0x61736b.net.
LICENSE AND COPYRIGHT
Copyright (C) 2007 by Ask Solem ask@0x61736b.net.
All rights reserved.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.6 or, at your option, any later version of Perl 5 you may have available.