GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages


Manual Reference Pages  -  PETAL::HASH::TEST (3)

.ds Aq ’

NAME

Petal::Hash::Test - Test and Tutorial Petal modifier

CONTENTS

SUMMARY

Petal modifiers are snippets of code which are used to extend the expression engine capabilities. This test shows how to write your own modifiers.

API

The modifier API is very, very simple. It consists of two elements:

    The package name

Your modifier should be called Petal::Hash::<SomeThing>, where <SomeThing> is the name that you want to give to your modifier.

For example, this modifier is called Petal::Hash::Test. Petal will automatically pick it the module up and assign it the ’test:’ prefix.



    package Petal::Hash::Test;
    use warnings;
    use strict;



The method CW$class->process ($hash, CW$argument);

This class method will define the modifier in itself.

* $class is the package name of your modifier (which might come in handy if you’re subclassing a modifier),

* $hash is the execution context, i.e. the objects and data which will ’fill’ your template,

* $argument is whatever was after your modifier’s prefix. For example, for the expression ’test:foo bar’, $argument would be ’foo bar’.

In this test / tutorial we’re going to write a modifier which uppercases a Petal expression.



  sub process
  {
      my $class    = shift;
      my $hash     = shift;
      my $argument = shift;
   
      return uc ($hash->get ($argument));
  }

  1;

  __END__



And that’s it! Simple!

AUTHOR

Jean-Michel Hiver

This module is redistributed under the same license as Perl itself.

SEE ALSO

The template hash module:



  Petal::Hash



Search for    or go to Top of page |  Section 3 |  Main Index


perl v5.20.3 PETAL::HASH::TEST (3) 2012-02-09

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with manServer 1.07.