Optional reference to a Safe compartment. If you do not provide this, one
is generated for you.
To enable some operations or share variables or functions with the template code, create a Safe compartment and configure it before passing it in as the value of the safe attribute:
<B>IMPORTANT NOTE:B> The safe_methods parameter is deprecated and will
be removed in future versions of Text::MicroMason (unless a Safe and
future-proof implementation can be found). If you use this parameter,
you will receive a warning via carp:
* WARNING: safe_methods is deprecated; please see the pod
This parameter works correctly with sufficiently old versions of the Safe module (prior to the release of perl 5.12.1), but modern versions of Safe make it impossible for a Safe compartment to run any code outside the compartment. Even with the object shared within the Safe compartment, there is currently no known way to call methods on it without defining the whole class within the compartment (which isnt safe).
If anyone has an appropriately safe solution that will allow safe_methods to work, please submit a patch to the module maintainer. Also see t/32-safe.t for tests related to safe_methods that are currently being skipped.
The following pod is provided for legacy purposes only. It is strongly recommended that you do not use this method. It is no longer allowed to call methods from within a Safe template, because it isnt actually safe.
A space-separated string of methods names to be supported by the Safe::Facade.
To control which Mason methods are available within the template, pass a safe_methods argument to new() followed by the method names in a space-separated string.
For example, to allow templates to include other templates, using $m->execute or the <& file &> include syntax, you would need to allow the execute method. Well also load the TemplateDir mixin with strict_root on to prevent inclusion of templates from outside the current directory.
eval_sub() Instead of the eval() used by the base class, this calls reval() on a Safe compartment. safe_compartment() Returns the Safe compartment passed by the user or generates a new one. safe_facade() Generates an instance of the Safe::Facade equipped with only the methods listed in the safe_methods attribute.
Code compiled in a Safe compartment only has access to a limited version of the template compiler in the $m variable, and can not make changes to the attributes of the real MicroMason object. This limited object is an instance of the Text::MicroMason::Safe::Facade class and can only perform certain pre-defined methods.
new() Creates a new hash-based instance mapping method names to subroutine references. facade_method() Calls a named method by looking up the corresponding subroutine and calling it. AUTOLOAD() Generates wrapper methods that call the facade_method() for any lowercase method name.
For an overview of this templating framework, see Text::MicroMason.
For distribution, installation, support, copyright and license information, see Text::MicroMason::Docs::ReadMe.
|perl v5.20.3||MICROMASON::SAFE (3)||2011-01-13|