2011-01-21 20:34:42 +00:00
|
|
|
#
|
2011-11-17 15:53:34 +00:00
|
|
|
# spec file for package perl-Text-MicroMason
|
2011-01-21 20:34:42 +00:00
|
|
|
#
|
2011-11-17 15:53:34 +00:00
|
|
|
# Copyright (c) 2011 SUSE LINUX Products GmbH, Nuernberg, Germany.
|
2011-01-21 20:34:42 +00:00
|
|
|
#
|
|
|
|
# All modifications and additions to the file contributed by third parties
|
|
|
|
# remain the property of their copyright owners, unless otherwise agreed
|
|
|
|
# upon. The license for this file, and modifications and additions to the
|
|
|
|
# file, is the same license as for the pristine package itself (unless the
|
|
|
|
# license for the pristine package is not an Open Source License, in which
|
|
|
|
# case the license is the MIT License). An "Open Source License" is a
|
|
|
|
# license that conforms to the Open Source Definition (Version 1.9)
|
|
|
|
# published by the Open Source Initiative.
|
|
|
|
|
|
|
|
# Please submit bugfixes or comments via http://bugs.opensuse.org/
|
|
|
|
#
|
|
|
|
|
2011-11-17 15:53:34 +00:00
|
|
|
|
|
|
|
|
2011-01-21 20:34:42 +00:00
|
|
|
Name: perl-Text-MicroMason
|
|
|
|
Version: 2.13
|
|
|
|
Release: 1
|
|
|
|
License: GPL+ or Artistic
|
|
|
|
%define cpan_name Text-MicroMason
|
|
|
|
Summary: Simple and Extensible Templating
|
|
|
|
Url: http://search.cpan.org/dist/Text-MicroMason/
|
|
|
|
Group: Development/Libraries/Perl
|
|
|
|
#Source: http://www.cpan.org/authors/id/F/FE/FERRENCY/Text-MicroMason-%{version}.tar.gz
|
2011-11-17 15:53:34 +00:00
|
|
|
Source: %{cpan_name}-%{version}.tar.gz
|
2011-01-21 20:34:42 +00:00
|
|
|
BuildRequires: perl(Class::MixinFactory) >= 0.9
|
|
|
|
BuildRequires: perl(Cwd) >= 2.21
|
|
|
|
BuildRequires: perl(File::Spec) >= 0.9
|
|
|
|
BuildRequires: perl
|
|
|
|
BuildRequires: perl-macros
|
|
|
|
Requires: perl(Class::MixinFactory) >= 0.9
|
|
|
|
Requires: perl(Cwd) >= 2.21
|
|
|
|
Requires: perl(File::Spec) >= 0.9
|
|
|
|
BuildRoot: %{_tmppath}/%{name}-%{version}-build
|
|
|
|
BuildArch: noarch
|
|
|
|
%{perl_requires}
|
|
|
|
|
|
|
|
%description
|
|
|
|
Text::MicroMason interpolates blocks of Perl code embedded into text
|
|
|
|
strings.
|
|
|
|
|
|
|
|
Each MicroMason object acts as a "template compiler," which converts
|
|
|
|
templates from text-with-embedded-code formats into ready-to-execute Perl
|
|
|
|
subroutines.
|
|
|
|
|
|
|
|
MicroMason Initialization
|
|
|
|
Use the new() method to create a Text::MicroMason object with the
|
|
|
|
appropriate mixins and attributes.
|
|
|
|
|
|
|
|
$mason = Text::MicroMason->new( %attribs );
|
|
|
|
|
|
|
|
You may pass attributes as key-value pairs to the new() method to save
|
|
|
|
various options for later use by the compile() method.
|
|
|
|
|
|
|
|
Template Compilation
|
|
|
|
To compile a text template, pass it to the compile() method to produce
|
|
|
|
a new Perl subroutine to be returned as a code reference:
|
|
|
|
|
|
|
|
$code_ref = $mason->compile( $type => $source, %attribs );
|
|
|
|
|
|
|
|
Any attributes provided to compile() will temporarily override the
|
|
|
|
persistent options defined by new(), for that template only.
|
|
|
|
|
|
|
|
You can provide the template as a text string, a file name, or an open
|
|
|
|
file handle:
|
|
|
|
|
|
|
|
$code_ref = $mason->compile( text => $template );
|
|
|
|
$code_ref = $mason->compile( text => \$template );
|
|
|
|
$code_ref = $mason->compile( file => $filename );
|
|
|
|
$code_ref = $mason->compile( handle => $fh );
|
|
|
|
$code_ref = $mason->compile( handle => \*FILE );
|
|
|
|
|
|
|
|
Template files are just plain text files that contains the string to be
|
|
|
|
parsed. The files may have any name and extension you wish. The
|
|
|
|
filename specified can either be absolute or relative to the program's
|
|
|
|
current directory.
|
|
|
|
|
|
|
|
Template Execution
|
|
|
|
To execute the template and obtain the output, call a compiled
|
|
|
|
function:
|
|
|
|
|
|
|
|
$result = $code_ref->( @arguments );
|
|
|
|
|
|
|
|
(Note that the $code_ref->() syntax is unavailable in older versions of
|
|
|
|
Perl; use the equivalent &$code_ref() syntax instead.)
|
|
|
|
|
|
|
|
As a shortcut, the execute method compiles and runs the template one
|
|
|
|
time:
|
|
|
|
|
|
|
|
$result = $mason->execute( $type => $source, @arguments );
|
|
|
|
$result = $mason->execute( $type => $source, \%attribs, @arguments );
|
|
|
|
|
|
|
|
Argument Passing
|
|
|
|
You can pass arguments to a template subroutine using positional or
|
|
|
|
named arguments.
|
|
|
|
|
|
|
|
For positional arguments, pass the argument list and read from @_ as
|
|
|
|
usual:
|
|
|
|
|
|
|
|
$mason->compile( text=>'Hello <% shift(@_) %>.' )->( 'Dave' );
|
|
|
|
|
|
|
|
For named arguments, pass in a hash of key-value pairs to be made
|
|
|
|
accessible in an '%ARGS' hash within the template subroutine:
|
|
|
|
|
|
|
|
$mason->compile( text=>'Hello <% $ARGS{name} %>.' )->( name=>'Dave' );
|
|
|
|
|
|
|
|
Additionally, you can use named arguments with the %args block syntax:
|
|
|
|
|
|
|
|
$mason->compile( text=>'<%args>$name</%args>Hello <% $name %>.' )->( name=>'Dave' );
|
|
|
|
|
|
|
|
Mixin Selection
|
|
|
|
Arguments passed to new() that begin with a dash will be added as mixin
|
|
|
|
classes.
|
|
|
|
|
|
|
|
$mason = Text::MicroMason->new( -Mixin1, %attribs, -Mixin2 );
|
|
|
|
|
|
|
|
Every MicroMason object inherits from an abstract Base class and some
|
|
|
|
set of mixin classes. By combining mixins you can create subclasses
|
|
|
|
with the desired combination of features. See the
|
|
|
|
Text::MicroMason::Base manpage for documentation of the base class,
|
|
|
|
including private methods and extension mechanisms.
|
|
|
|
|
|
|
|
If you call the new method on Text::MicroMason, it automatically
|
|
|
|
includes the HTMLMason mixin, which provides the standard template
|
|
|
|
syntax. If you want to create an object without the default HTMLMason
|
|
|
|
functionality, call Text::MicroMason::Base->new() instead.
|
|
|
|
|
|
|
|
Some mixins define the syntax for a particular template format. You
|
|
|
|
will generally need to select one, and only one, of the mixins listed
|
|
|
|
in the /"TEMPLATE SYNTAXES" manpage.
|
|
|
|
|
|
|
|
Other mixins provide optional functionality. Those mixins may define
|
|
|
|
additional public methods, and may support or require values for
|
|
|
|
various additional attributes. For a list of such mixin classes, see
|
|
|
|
the /"MIXIN FEATURES" manpage.
|
|
|
|
|
|
|
|
%prep
|
|
|
|
%setup -q -n %{cpan_name}-%{version}
|
|
|
|
|
|
|
|
%build
|
|
|
|
%{__perl} Makefile.PL INSTALLDIRS=vendor
|
|
|
|
%{__make} %{?_smp_mflags}
|
|
|
|
|
|
|
|
%check
|
|
|
|
%{__make} test
|
|
|
|
|
|
|
|
%install
|
|
|
|
%perl_make_install
|
|
|
|
%perl_process_packlist
|
|
|
|
%perl_gen_filelist
|
|
|
|
|
|
|
|
%clean
|
|
|
|
%{__rm} -rf %{buildroot}
|
|
|
|
|
|
|
|
%files -f %{name}.files
|
|
|
|
%defattr(644,root,root,755)
|
|
|
|
|
|
|
|
%changelog
|