Skip to content

Commit

Permalink
Merge pull request #110 from paultcochrane/pr/readme-typo-fix
Browse files Browse the repository at this point in the history
README typo fix
  • Loading branch information
racke committed Aug 4, 2015
2 parents 1a4ef67 + f135e5b commit 4b247c1
Showing 1 changed file with 36 additions and 36 deletions.
72 changes: 36 additions & 36 deletions lib/Template/Flute.pm
Expand Up @@ -90,7 +90,7 @@ The resulting output would be:
In other words, rather than including a templating language within your
templates which your designers must master and which could interfere with
previews in WYSWYG tools, CSS selectors in the template are tied to your
previews in WYSIWYG tools, CSS selectors in the template are tied to your
data structures or objects by a specification provided by the programmer.
Expand Down Expand Up @@ -303,7 +303,7 @@ sub new {
$filter_opts = {};
$filter_class = {};
$filter_objects = {};

$self = {iterators => {},
translate_attributes => [qw/placeholder input.value.type.submit/],
@_,
Expand All @@ -314,7 +314,7 @@ sub new {
};

bless $self, $class;

if (exists $self->{specification}
&& ! ref($self->{specification})) {
# specification passed as string
Expand Down Expand Up @@ -368,7 +368,7 @@ sub _set_pattern {
sub _bootstrap {
my ($self, $snippet) = @_;
my ($parser_name, $parser_spec, $spec_file, $spec, $template_file, $template_object);

unless ($self->{specification}) {
unless ($self->{specification_file}) {
# try to derive specification file name from template file name
Expand All @@ -388,11 +388,11 @@ sub _bootstrap {
sub _bootstrap_specification {
my ($self, $source, $specification) = @_;
my ($parser_name, $parser_spec, $spec_file);

if ($parser_name = $self->{specification_parser}) {
# load parser class
my $class;

if ($parser_name =~ /::/) {
$class = $parser_name;
} else {
Expand All @@ -414,7 +414,7 @@ sub _bootstrap_specification {
} else {
$parser_spec = new Template::Flute::Specification::XML;
}

if ($source eq 'file') {
unless ($self->{specification} = $parser_spec->parse_file($specification)) {
die "$0: error parsing $specification: " . $parser_spec->error() . "\n";
Expand All @@ -427,13 +427,13 @@ sub _bootstrap_specification {
}
}


my ($name, $iter);

while (($name, $iter) = each %{$self->{iterators}}) {
$self->{specification}->set_iterator($name, $iter);
}

if (my %patterns = $self->{specification}->patterns) {
foreach my $k (keys %patterns) {
$self->_set_pattern($k, $patterns{$k});
Expand All @@ -448,7 +448,7 @@ sub _bootstrap_template {
my ($template_object);

$template_object = new Template::Flute::HTML(uri => $self->{uri});

if ($source eq 'file') {
$template_object->parse_file($template, $self->{specification}, $snippet);
$self->{template} = $template_object;
Expand Down Expand Up @@ -478,24 +478,24 @@ Returns HTML output.

sub process {
my ($self, $params) = @_;


unless ($self->{template}) {
$self->_bootstrap($params->{snippet});
}

if ($self->{i18n}) {
# translate static text first
$self->{template}->translate($self->{i18n},
@{$self->{translate_attributes}});
}

my $html = $self->_sub_process(
$self->{template}->{xml},
$self->{specification}->{xml}->root,
$self->{template}->{xml},
$self->{specification}->{xml}->root,
$self->{'values'},
$self->{specification},
$self->{template},
$self->{template},
0,
0,
);
Expand Down Expand Up @@ -552,15 +552,15 @@ sub _sub_process {
my ($template, %list_active);
# Use root spec or sub-spec
my $specification = $spec || $self->_bootstrap_specification(string => "<specification>".$spec_xml->sprint."</specification>", 1);

if($root_template){
$template = $root_template;
}
else {
$template = new Template::Flute::HTML;
$template->parse("<flutexml>".$html->sprint."</flutexml>", $specification, 1);
}

my $classes = $specification->{classes};
my ($dbobj, $iter, $sth, $row, $lel, $query, %skip, %iter_names);

Expand All @@ -581,8 +581,8 @@ sub _sub_process {
}
}
push @{$spec_elements->{$type}}, $elt;
}

}

while (my ($name, $value) = each %iter_names) {
next if $name =~ /\./;
Expand Down Expand Up @@ -635,7 +635,7 @@ sub _sub_process {
my $iterator = $elt->{'att'}->{'iterator'} || '';
my $sub_spec = $elt->copy();
my $element_template = $classes->{$spec_class}->[0]->{elts}->[0];

unless($element_template){
next;
}
Expand Down Expand Up @@ -795,7 +795,7 @@ sub _sub_process {
}

# Values
for my $elt ( @{$spec_elements->{value}}, @{$spec_elements->{param}}, @{$spec_elements->{field}} ){
for my $elt ( @{$spec_elements->{value}}, @{$spec_elements->{param}}, @{$spec_elements->{field}} ){
if ($elt->tag eq 'param') {
my $name = $spec_xml->att('name');

Expand Down Expand Up @@ -824,7 +824,7 @@ sub _sub_process {
my $spec_id = $elt->{'att'}->{'id'};
my $spec_name = $elt->{'att'}->{'name'};
my $spec_class = $elt->{'att'}->{'class'} ? $elt->{'att'}->{'class'} : $spec_name;

# Use CLASS or ID if set
my $spec_clases = [];
if ($spec_id){
Expand All @@ -833,7 +833,7 @@ sub _sub_process {
else {
$spec_clases = $classes->{$spec_class};
}

for my $spec_class (@$spec_clases){
# check if it's a form and it's already filled
if (exists $spec_class->{form} && $spec_class->{form}) {
Expand Down Expand Up @@ -896,7 +896,7 @@ sub _sub_process {
}
}

return $count ? $template->{xml}->root() : $template->{xml};
return $count ? $template->{xml}->root() : $template->{xml};
}

sub _replace_within_elts {
Expand All @@ -922,7 +922,7 @@ sub _replace_within_elts {
$elt->paste(first_child => $elt->former_parent);
}
}

if ($zref->{rep_sub}) {
# call subroutine to handle this element
$zref->{rep_sub}->($elt, $rep_str);
Expand Down Expand Up @@ -965,7 +965,7 @@ sub _replace_within_elts {
} elsif ($zref->{rep_elt}) {
# use provided text element for replacement
$zref->{rep_elt}->set_text($rep_str);
} else {
} else {
$elt->set_text($rep_str) if defined $rep_str;
}
}
Expand All @@ -979,7 +979,7 @@ Processes HTML template and returns L<Template::Flute::HTML> object.

sub process_template {
my ($self) = @_;

unless ($self->{template}) {
$self->_bootstrap();
}
Expand Down Expand Up @@ -1031,7 +1031,7 @@ sub _replace_record {
}
#debug "$name has value ";
#debug "'$rep_str'";

# Template specified value if value defined
if ($value->{value}) {
if ($rep_str) {
Expand Down Expand Up @@ -1089,7 +1089,7 @@ sub _replace_record {
$value->{increment}->increment();
}
#return undef unless defined $rep_str;

if (ref($value->{op}) eq 'CODE') {
_replace_within_elts($value, $rep_str, $value->{op}, $elts);
}
Expand Down Expand Up @@ -1148,7 +1148,7 @@ sub _filter {
$filter = $self->{_filter_subs}->{$name};
return $filter->($value);
}

unless (exists $self->{_filter_objects}->{$name}) {
# try to bootstrap filter
unless ($class = $self->{_filter_class}->{$name}) {
Expand All @@ -1174,7 +1174,7 @@ sub _filter {
}

$filter_obj = $self->{_filter_objects}->{$name};

if ($filter_obj->can('twig')) {
$element->{op} = sub {$filter_obj->twig(@_)};
}
Expand Down Expand Up @@ -1415,7 +1415,7 @@ sub value {
else {
$include_file = $value->{include};
}

# process template and include it
%args = (template_file => $include_file,
auto_iterators => $self->{auto_iterators},
Expand All @@ -1424,7 +1424,7 @@ sub value {
values => $value->{field} ? $self->{values}->{$value->{field}} : $self->{values},
uri => $self->{uri},
);

$raw_value = Template::Flute->new(%args)->process();
}
elsif (exists $value->{field}) {
Expand Down Expand Up @@ -1481,7 +1481,7 @@ sub value {
if (wantarray) {
return ($raw_value, $rep_str);
}

return $rep_str;
}

Expand Down Expand Up @@ -1781,7 +1781,7 @@ is usually more convenient.
=item filter
=item sort
=item sort
=item i18n
Expand Down

0 comments on commit 4b247c1

Please sign in to comment.