Template::Declare::Anon - B<Deprecated> Anonymous Template::Declare templates


Template-Declare-Anon documentation Contained in the Template-Declare-Anon distribution.

Index


Code Index:

NAME

Top

Template::Declare::Anon - Deprecated Anonymous Template::Declare templates

SYNOPSIS

Top

This module is no longer necessary. The following code will just work:

	use Template::Declare::Tags 'HTML';

	print html {
		body {
			p { "foo" }
		}
	};

SEE ALSO

Top

Template::Declare

AUTHOR

Top

Yuval Kogman <nothingmuch@woobling.org>

COPYRIGHT & LICENSE

Top


Template-Declare-Anon documentation Contained in the Template-Declare-Anon distribution.

#!/usr/bin/perl

package Template::Declare::Anon;

use strict;
use warnings;

use base qw/Exporter/;

our $VERSION = "0.03";

use Template::Declare ();
use Template::Declare::Tags ();

use overload '""' => \&process;

our @EXPORT = qw( anon_template process );

sub anon_template (&) {
	my $self = shift;
	bless $self, __PACKAGE__;
}

sub process {
	my ( $template, @args ) = @_;

	local %Template::Declare::Tags::ELEMENT_ID_CACHE = ();
	local $Template::Declare::Tags::self = $Template::Declare::Tags::self || "Template::Declare";

	Template::Declare->new_buffer_frame;

	&$template($Template::Declare::Tags::self, @args);

	my $output = Template::Declare->buffer->data;

	Template::Declare->end_buffer_frame;

	return $output;
}

__PACKAGE__;

__END__