Jifty
view release on metacpan or search on metacpan
lib/Jifty/View/Declare/CoreTemplates.pm view on Meta::CPAN
package Jifty::View::Declare::CoreTemplates;
use strict;
use warnings;
use Jifty::View::Declare -base;
use Scalar::Defer;
=head1 NAME
Jifty::View::Declare::CoreTemplates - Templates Jifty can't function without
=head1 DESCRIPTION
This library contains templates that Jifty can't function without:
=over
=item Validate
=item Autocomplete
=item Canonicalize
=item YAML and XML webservice endpoints for core jifty functionality
=back
=cut
=for later
These templates are still in Masonland. we're doing something wrong with escaping in them
template '__jifty/autocomplete.xml' => sub {
# Note: the only point to this file is to set the content_type; the actual
# behavior is accomplished inside the framework. It will go away once we
# have infrastructure for serving things of various content-types.
Jifty->web->response->content_type('text/xml; charset=utf-8');
my $ref = Jifty->web->response->result('autocomplete')->content;
my @options = @{ $ref->{'completions'} || [] };
body {
ul {
foreach my $item (@options) {
if ( !ref($item) ) {
li { $item };
}
elsif ( exists $item->{label} ) {
li {
with( class => "informal" ), span { $item->{label} };
with( class => "hidden_value" ),
span { $item->{value} };
};
}
else {
li { $item->{value} };
}
}
};
};
};
template '__jifty/validator.xml' => sub {
Jifty->web->response->content_type('text/xml; charset=utf-8');
my $output = "";
use XML::Writer;
my $writer = XML::Writer->new( OUTPUT => \$output );
$writer->xmlDecl( "UTF-8", "yes" );
$writer->startTag("validation");
for my $ra ( Jifty->web->request->actions ) {
my $action = Jifty->web->new_action_from_request($ra);
$writer->startTag( "validationaction", id => $action->register_name );
for my $arg ( $action->argument_names ) {
if ( not $action->arguments->{$arg}->{ajax_validates} ) {
$writer->emptyTag( "ignored",
id => $action->error_div_id($arg) );
$writer->emptyTag( "ignored",
id => $action->warning_div_id($arg) );
}
elsif ( not defined $action->argument_value($arg)
or length $action->argument_value($arg) == 0 )
{
$writer->emptyTag( "blank", id => $action->error_div_id($arg) );
( run in 1.602 second using v1.01-cache-2.11-cpan-524268b4103 )