The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

WWW::MenuGrinder::Plugin::Variables - WWW::MenuGrinder plugin that does variable substitutions and checks.

VERSION

version 0.01_01

DESCRIPTION

WWW::MenuGrinder::Plugin::Variables is a plugin for WWW::MenuGrinder. You should not use it directly, but include it in the plugins section of a WWW::MenuGrinder config.

When loaded, this plugin will interpolate named variables into menu fields from the application context. It will also remove any item containing a need_var key naming a variable that does exist (and all of that item's descendents), as well as any item containing a no_var key naming a variable that does exist (and all of that item's descendents).

The variable interpolation syntax is akin to Perl's, except that curly braces are mandatory. For example, the string "Hello, ${object}!" becomes "Hello, world!" if the variable object holds the value "world".

Configuration

  • substitute_fields

    An arrayref containing the names of menu keys to perform variable substitution on. Defaults to ['label'].

Required Methods

In order to load this plugin your WWW::MenuGrinder subclass must implement the method get_variable accepting a variable name (without ${}) and returning the value of that variable, or undef if the variable does not exist or is not set. Existence and definedness are not distinguished. The source of "variables" is left entirely to the implementer, but might be the stash, the session, the application configuration, or some combination.

AUTHOR

  Andrew Rodland <andrew@hbslabs.com>

COPYRIGHT AND LICENSE

This software is copyright (c) 2009 by HBS Labs, LLC..

This is free software; you can redistribute it and/or modify it under the same terms as perl itself.