| 1 | =head1 NAME | ||
| 2 | |||
| 3 | Template::TAL::Language::METAL - Implement METAL | ||
| 4 | |||
| 5 | =head1 SYNOPSIS | ||
| 6 | |||
| 7 | =head1 DESCRIPTION | ||
| 8 | |||
| 9 | This module is not implemented - it's here as a placeholder for the | ||
| 10 | METAL implementation. | ||
| 11 | (http://www.zope.org/Wikis/DevSite/Projects/ZPT/METAL/MetalSpecification11) | ||
| 12 | |||
| 13 | =cut | ||
| 14 | |||
| 15 | package Template::TAL::Language::METAL; | ||
| 16 | use warnings; | ||
| 17 | use strict; | ||
| 18 | use Carp qw( croak ); | ||
| 19 | use base qw( Template::TAL::Language ); | ||
| 20 | use Template::TAL::ValueParser; | ||
| 21 | |||
| 22 | sub namespace { 'http://xml.zope.org/namespaces/metal' } | ||
| 23 | |||
| 24 | sub tags { qw( define-macro extend-macro use-macro define-slot use-slot ) } | ||
| 25 | |||
| 26 | =head1 METHODS | ||
| 27 | |||
| 28 | =over | ||
| 29 | |||
| 30 | =item provider | ||
| 31 | |||
| 32 | =cut | ||
| 33 | |||
| 34 | sub provider { | ||
| 35 | my $self = shift; | ||
| 36 | return $self->{provider} unless @_; | ||
| 37 | $self->{provider} = shift; | ||
| 38 | return $self; | ||
| 39 | } | ||
| 40 | |||
| 41 | sub process_define_macro { | ||
| 42 | my ($self, $parent, $node, $value, $local_context, $global_context) = @_; | ||
| 43 | $self->{macros}{ $value } = $node; | ||
| 44 | return (); # remove the macro definition node. | ||
| 45 | } | ||
| 46 | |||
| 47 | sub process_extend_macro { | ||
| 48 | my ($self, $parent, $node, $value, $local_context, $global_context) = @_; | ||
| 49 | return $node; # don't replace node | ||
| 50 | } | ||
| 51 | |||
| 52 | sub process_use_macro { | ||
| 53 | my ($self, $parent, $node, $value, $local_context, $global_context) = @_; | ||
| 54 | my $macro = $self->{macros}{$value} or die "no such macro '$value'\n"; | ||
| 55 | my $new = $macro->cloneNode(1); # deep clone | ||
| 56 | $parent->_process_node( $new, $local_context, $global_context ); | ||
| 57 | return $new; | ||
| 58 | } | ||
| 59 | |||
| 60 | sub process_define_slot { | ||
| 61 | my ($self, $parent, $node, $value, $local_context, $global_context) = @_; | ||
| 62 | return $node; # don't replace node | ||
| 63 | } | ||
| 64 | |||
| 65 | sub process_use_slot { | ||
| 66 | my ($self, $parent, $node, $value, $local_context, $global_context) = @_; | ||
| 67 | return $node; # don't replace node | ||
| 68 | } | ||
| 69 | |||
| 70 | =back | ||
| 71 | |||
| 72 | =head1 COPYRIGHT | ||
| 73 | |||
| 74 | Written by Tom Insam, Copyright 2005 Fotango Ltd. All Rights Reserved | ||
| 75 | |||
| 76 | This program is free software; you can redistribute | ||
| 77 | it and/or modify it under the same terms as Perl itself. | ||
| 78 | |||
| 79 | =cut | ||
| 80 | |||
| 81 | 1; |