forked from racke/Template-Flute
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge commit 'ed9151c0238dd7f6001ac0e2dfa1f2eb6ff25bbe'
- Loading branch information
Showing
9 changed files
with
199 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package Template::Flute::Filter::LowerDash; | ||
|
||
use strict; | ||
use warnings; | ||
|
||
use base 'Template::Flute::Filter'; | ||
|
||
=head1 NAME | ||
Template::Flute::Filter::LowerDash - LowerDashcase filter | ||
=head1 DESCRIPTION | ||
LowerDashcase filter. Replace spaces with dashes and make lowercase. | ||
=head1 METHODS | ||
=head2 filter | ||
LowerDashcase filter. | ||
=cut | ||
|
||
sub filter { | ||
my $self = shift; | ||
|
||
(my $value = shift) =~ s/\s+/-/g; | ||
|
||
return lc($value); | ||
} | ||
|
||
=head1 AUTHOR | ||
William Carr (Mr. Maloof), <[email protected]> | ||
=head1 LICENSE AND COPYRIGHT | ||
Copyright 2011 Stefan Hornburg (Racke) <[email protected]>. | ||
This program is free software; you can redistribute it and/or modify it | ||
under the terms of either: the GNU General Public License as published | ||
by the Free Software Foundation; or the Artistic License. | ||
See http://dev.perl.org/licenses/ for more information. | ||
=cut | ||
|
||
1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#! perl | ||
# | ||
# Test for lowerdash filter | ||
|
||
use strict; | ||
use warnings; | ||
use Test::More tests => 3; | ||
|
||
use Template::Flute; | ||
|
||
# lowerdash filter | ||
my $xml = <<EOF; | ||
<specification name="filters"> | ||
<value name="text" filter="lower_dash" /> | ||
</specification> | ||
EOF | ||
|
||
my $html = <<EOF; | ||
<div class="text">foo</div> | ||
EOF | ||
|
||
my $tests = { | ||
'Red Wine' => 'red-wine', | ||
'Red Wine is Delicious' => 'red-wine-is-delicious', | ||
'Red Wine is Delicious' => 'red-wine-is-delicious', | ||
}; | ||
for my $key ( keys %$tests ) { | ||
my $flute = Template::Flute->new( | ||
specification => $xml, | ||
template => $html, | ||
values => { text => $key } | ||
); | ||
my $ret = $flute->process(); | ||
ok( $ret =~ m{<div class="text">$tests->{$key}</div>}, | ||
qq{lower_dash filter: $ret} ); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#! perl | ||
# | ||
# Test for <script> elements inside HTML snippets insertd with op="hook". | ||
|
||
use strict; | ||
use warnings; | ||
|
||
use Test::More; | ||
use Template::Flute; | ||
|
||
my ($spec, $html, $flute, $out); | ||
|
||
# value with op=hook, using class | ||
$spec = q{<specification> | ||
<value name="content" op="hook"/> | ||
</specification> | ||
}; | ||
|
||
$html = q{<div class="content">CONTENT</div>}; | ||
|
||
$flute = Template::Flute->new(template => $html, | ||
specification => $spec, | ||
values => {content => q{<script type="text/javascript"></script>}}, | ||
); | ||
|
||
$out = $flute->process(); | ||
|
||
like($out, qr{\Q<div class="content"><script type="text/javascript"></script></div>\E}, | ||
'value op=hook test with <script> elements inside') | ||
or diag $out; | ||
|
||
done_testing; |