diff options
author | dakkar <dakkar@luxion> | 2009-01-07 12:51:13 +0000 |
---|---|---|
committer | dakkar <dakkar@luxion> | 2009-01-07 12:51:13 +0000 |
commit | 8d25800c67ad65defd98771bba2331ee64104f98 (patch) | |
tree | 622f61a0c5609c61904d9da3a6ab4b8db6688a24 /lib/WebCoso/TT.pm | |
parent | a parte i namespace sbagliati, direi che i feed possono andare bene (diff) | |
download | WebCoso-8d25800c67ad65defd98771bba2331ee64104f98.tar.gz WebCoso-8d25800c67ad65defd98771bba2331ee64104f98.tar.bz2 WebCoso-8d25800c67ad65defd98771bba2331ee64104f98.zip |
feed fatti, e pure col test
manca: testare feed intl, fare feed dei tag, mettere i tag nei feed
git-svn-id: svn://luxion/repos/WebCoso/trunk@402 fcb26f47-9200-0410-b104-b98ab5b095f3
Diffstat (limited to 'lib/WebCoso/TT.pm')
-rw-r--r-- | lib/WebCoso/TT.pm | 36 |
1 files changed, 30 insertions, 6 deletions
diff --git a/lib/WebCoso/TT.pm b/lib/WebCoso/TT.pm index b6962fd..15e2072 100644 --- a/lib/WebCoso/TT.pm +++ b/lib/WebCoso/TT.pm @@ -4,18 +4,43 @@ use warnings; use WebCoso::Common; use Path::Class; use Template; +use Template::Stash; use Log::Log4perl ':easy'; +$Template::Stash::HASH_OPS->{sortf}=sub { + my ($hash,$field)=@_; + + if ($field) { + return [ sort { lc $hash->{$a}{$field} cmp lc $hash->{$b}{$field} } (keys %$hash )]; + } + else { + return [ sort { lc $hash->{$a} cmp lc $hash->{$b} } (keys %$hash )]; + } +}; + +$Template::Stash::HASH_OPS->{nsortf}=sub { + my ($hash,$field)=@_; + + if ($field) { + return [ sort { $hash->{$a}{$field} <=> $hash->{$b}{$field} } (keys %$hash )]; + } + else { + return [ sort { $hash->{$a} <=> $hash->{$b} } (keys %$hash )]; + } +}; + sub new { my ($class,%opts)=@_; - $opts{stash}||={ + my $self={%opts}; + bless $self,$class; + + $self->{stash}||={ dstUriFor => \&WebCoso::Common::dstUriFor, isLang => \&WebCoso::Common::isLang, + atomIdFor => sub{WebCoso::Common::getAtomIdFor($self->{fc},@_)}, }; - my $self={%opts}; - $self->{template_provider}=Template::Provider->new({ INCLUDE_PATH=> $self->{TMPLPATH}, ABSOLUTE=>1, @@ -57,14 +82,13 @@ sub new { pop @{$self->{template_provider}->include_path}; }; - bless $self,$class; + return $self; } - sub expandTT { my ($self)=@_; return $self->{expander} - } +} 1; |