Text::UberText::Dispatch

Text::UberText::Dispatch is a Perl module that keeps track of loaded code modules that extend the UberText template language.
Download

Text::UberText::Dispatch Ranking & Summary

Advertisement

  • Rating:
  • License:
  • Perl Artistic License
  • Price:
  • FREE
  • Publisher Name:
  • Chris Josephes
  • Publisher web site:
  • http://search.cpan.org/~chrisj/ubertext-0.95/Dispatch/Dispatch.pm

Text::UberText::Dispatch Tags


Text::UberText::Dispatch Description

Text::UberText::Dispatch is a Perl module that keeps track of loaded code modules that extend the UberText template language. Text::UberText::Dispatch is a Perl module that keeps track of loaded code modules that extend the UberText template language. A Dispatch object is automatically created for new Text::UberText objects.EXTENDING UBERTEXTIf you write a module that integrates with an UberText template, the UberText object needs to be aware of it.$uber=Text::UberText->new();$uber->extend($myObject);$uber->extend(MyClass);The UberText module passes the object or class name to the Text::UberText::Dispatch object. The Dispatch object then calls the uberText method of the module it was passed.The uberText method will need to return 3 variables. The first is the object that the dispatch table will need to use when it encounters your custom namesapce. The second variable is the preferred namespace the object will use, and the third is an anonymous hash containing the dispatch table matching UberText tags and Perl code.EXAMPLECustom Module package Automobile; $Dispatch={ "make" => &make, "model" => &model, "color" => &color, "odometer' => &mileage, }; sub uberText { my ($self)=shift; return ($self,"my.automobile",$Dispatch); } sub make { my ($self)=shift; return ($self->{color}); } sub mileage { my ($self,$node)=@_; my ($value); if ($node->commandValue() eq "trip") { $value=$self->{odometer}->{trip}; } else { $value=$self->{odometer}->{basic}; } if ($node->getOptValue("units") eq "metric") { # convert miles to kilometers $value=$value*1.61; } return $value; }UberText FileThe manufacturer of my car is It is described as a .My last trip was kilometers. Requirements: · Perl


Text::UberText::Dispatch Related Software