1use warnings; 2use strict; 3 4package Wifty::UI; 5use base qw/Template::Declare/; 6use Template::Declare::Tags; 7 8template simple => sub { 9 my $self = shift; 10 html { 11 head {}; 12 body { outs( 'This is my content from' . $self ); }; 13 } 14 15}; 16 17private template 'private-content' => sub { 18 with( id => 'body' ), div { 19 outs('This is my content from'.$self); 20 }; 21}; 22 23package main; 24Template::Declare->init(dispatch_to => ['Wifty::UI']); 25 26use Test::More tests => 3; 27require "t/utils.pl"; 28{ 29 local $Template::Declare::Tags::self = 'Wifty::UI'; 30 my $simple = Template::Declare::Tags::show('simple') ; 31 like( $simple, qr'This is my content' ); 32 like( $simple, qr'Wifty::UI', '$self is correct in template block' ); 33 ok_lint($simple); 34} 35 36 371; 38