-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Tests added, need to fix repeat with nested elements.
- Loading branch information
1 parent
51cf1e5
commit 2bd1877
Showing
5 changed files
with
84 additions
and
19 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 was deleted.
Oops, something went wrong.
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 @@ | ||
#!/usr/bin/env perl6 | ||
|
||
BEGIN { @*INC.push: './lib' } | ||
|
||
use Test; | ||
use Flower; | ||
|
||
plan 5; | ||
|
||
my $xml = '<?xml version="1.0"?>'; | ||
|
||
my $template = '<test><item petal:define="test my_test_var" petal:content="test"/></test>'; | ||
my $flower = Flower.new(:template($template)); | ||
is $flower.parse(my_test_var => 'Hello World'), $xml~'<test><item>Hello World</item></test>', 'petal:define and petal:content'; | ||
|
||
$template = '<test><replaced petal:replace="hello">This will be replaced</replaced></test>'; | ||
$flower = Flower.new(:template($template)); | ||
is $flower.parse(hello => 'Hello World'), $xml~'<test>Hello World</test>', 'petal:replace'; | ||
|
||
$template = '<test><true petal:condition="hello">This is true</true><false petal:condition="notreal">This is false</false><right petal:condition="true:hello"/><wrong petal:condition="false:hello"/></test>'; | ||
$flower = Flower.new(:template($template)); | ||
is $flower.parse(hello => 'Hello World'), $xml~'<test><true>This is true</true><right/></test>', 'petal:condition'; | ||
|
||
$template = '<test><div petal:omit-tag="">Good <b petal:omit-tag="hello">Day</b> Mate</div></test>'; | ||
#$template = '<test><div petal:omit-tag="string:1">Good Day Mate</div></test>'; | ||
$flower = Flower.new(:template($template)); | ||
is $flower.parse(hello => 'hello world'), $xml~'<test>Good Day Mate</test>', 'petal:omit-tag'; | ||
|
||
$template = '<test><attrib petal:attributes="hello hello; cya goodbye"/></test>'; | ||
$flower = Flower.new(:template($template)); | ||
is $flower.parse(hello => 'Hello World', goodbye => 'Goodbye Universe'), $xml~'<test><attrib hello="Hello World" cya="Goodbye Universe"/></test>', 'petal:attributes'; | ||
|
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,25 @@ | ||
#!/usr/bin/env perl6 | ||
|
||
BEGIN { @*INC.push: './lib' } | ||
|
||
use Test; | ||
use Flower; | ||
|
||
plan 2; | ||
|
||
my $xml = '<?xml version="1.0"?>'; | ||
|
||
my $template = '<test><item petal:repeat="item items" petal:attributes="alt item/alt" petal:content="item/content"/></test>'; | ||
my $flower = Flower.new(:template($template)); | ||
my @items = ( | ||
{ :alt<One>, :content<First> }, | ||
{ :alt<Two>, :content<Second> }, | ||
{ :alt<Three>, :content<Third> }, | ||
); | ||
|
||
is $flower.parse(:items(@items)), $xml~'<test><item alt="One">First</item><item alt="Two">Second</item><item alt="Three">Third</item></test>', 'petal:repeat'; | ||
|
||
$template = '<test><div petal:repeat="item items" petal:omit-tag=""><tr><td petal:content="item/alt"/></tr><tr><td petal:content="item/content"/></tr></div></test>'; | ||
$flower = Flower.new(:template($template)); | ||
is $flower.parse(:items(@items)), $xml~'<test><tr><td>One</td><td>First</td></tr><tr><td>Two</td><td>Second</td></tr><tr><td>Three</td><td>Third</td></tr></test>', 'petal:repeat with nested elements and omit-tag'; | ||
|
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,23 @@ | ||
#!/usr/bin/env perl6 | ||
|
||
## TODO: Separate out the string: parsing from the uc: parsing. | ||
## Add a separate set of tests for Flower::Utils::Text, and one | ||
## for all modifiers in the DefaultModifiers set. | ||
|
||
BEGIN { @*INC.push: './lib' } | ||
|
||
use Test; | ||
use Flower; | ||
use Flower::Utils::Text; | ||
|
||
plan 1; | ||
|
||
my $xml = '<?xml version="1.0"?>'; | ||
|
||
my $template = '<test><upper petal:content="uc:string:A test of ${name}, in uppercase."/></test>'; | ||
my $flower = Flower.new(:template($template)); | ||
|
||
$flower.add-modifiers(Flower::Utils::Text::all()); | ||
|
||
is $flower.parse(name => 'Flower'), $xml~'<test><upper>A TEST OF FLOWER, IN UPPERCASE.</upper></test>', 'string: and custom :uc modifiers'; | ||
|