Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Cleanups and updated README

  • Loading branch information...
commit 10724e5576951c900970ab3530f1fa72db5391eb 1 parent cb40118
Timothy Totten authored
View
2  META.info
@@ -2,6 +2,6 @@
"name" : "Flower",
"version" : "*",
"description" : "XML Application Languages, including TAL.",
- "depends" : [ "Exemel", "DateTime::Utils" ],
+ "depends" : [ "XML", "DateTime::Utils" ],
"source-url" : "git://github.com/supernovus/flower.git"
}
View
111 README → README.md
@@ -1,4 +1,13 @@
-=== Flower: XML Application Languages ===
+# Flower: XML Application Languages
+
+## BIG IMPORTANT NOTE
+
+Flower is currently horribly broken and does not work, like at all.
+It's been unmaintained for a while and has suffered some bitrot.
+
+I am planning to get it back into a working shape again soon.
+
+## Introduction
Flower is a library for building and using XML Application Languages.
An XML Application Language can be anything that takes an XML document,
@@ -13,33 +22,14 @@ in further ideas from Template::TAL, PHPTAL, and some of my own custom XML
concepts. The original TAL/METAL/TALES parsers are still included, and can
be easily used by using Flower::TAL, which is included (see below.)
-= Requirements =
-
- - Rakudo Perl 6
- http://rakudo.org/
- NOTE: Unlike most of my libraries, Exemel and Flower only work on the
- "ng" branch of Rakudo, and not the "nom" branch. Once grammars/regexes are
- working fully in "nom", I'll make sure both libraries work on "nom" again.
-
- - Exemel
- The XML library that powers Flower.
- http://github.com/supernovus/exemel/
-
-= Optional libraries:
-
- - DateTime::Utils
- Needed if you want to use Flower::TAL::TALES::Date
- which is included in Flower::TAL's list of plugins.
- http://github.com/supernovus/temporal-utils/
-
-=== Flower::TAL ===
+## Flower::TAL
This is an easily loadable library that extends Flower and automatically
loads the Flower::TAL::TAL, Flower::TAL::METAL application languages
by default, and offers the ability to easily load plugins for the
Flower::TAL::TALES attribute parser (used by Flower::TAL::TAL)
-= Major Differences from Petal =
+### Differences from Petal (also PHPTAL and Zope)
* The default local namespace is 'tal', and to override it, you must
declare http://xml.zope.org/namespaces/tal instead of the Petal namespace.
@@ -56,7 +46,7 @@ Flower::TAL::TALES attribute parser (used by Flower::TAL::TAL)
the XML tree. Send an array of Exemel objects, and they will additionally
be parsed for TAL statements.
* Nested repeats cannot use the same attribute name, it will get clobbered.
- * The built-in repeat object is implemented as per the Zope/PHPTAL, not
+ * The built-in repeat object is implemented as per Zope and PHPTAL, not
the Petal version. Note: it does not support the 'letter' or 'Letter'
attributes, but instead has some new methods that take paramters:
'every xx' the number (not the index) is divisible by xx.
@@ -75,40 +65,47 @@ The above list will be updated as this project is developed, as I'm sure
other changes will be introduced that will be a gotchya for users of Petal,
Zope or PHPTAL.
-= Flower::TAL Plugins =
+### Flower::TAL Plugins
Inspired by Petal::Utils, Flower includes a bunch of libraries in the
Flower::TAL::TALES:: namespace. These are also available using Flower::TAL's
add-tales() method.
- - Text, same as the :text set from Petal::Utils
- lc: make the string lowercase.
- uc: make the string uppercase.
- ucfirst: make the first letter of the string uppercase.
- substr: extract a portion of the string.
- printf: format a string or object in a specified way.
- - List, similar to the :list set from Petal::Utils.
- group: turns a flat Array into a nested Array, where each inner
- Array has a set number of elements in it.
- sort: sort the array using the default sort algorithm.
- limit: only return the first number of items from the list.
- shuffle: shuffle the list into a random order.
- pick: pick a set number of items randomly from the list.
- reverse: reverse the contents of the list.
- - Date, similar to the :date set from Petal::Utils, using on DateTime::Utils
- date: Builds a DateTime object using specified paramters.
- time: Builds a DateTime object from a Unix epoch.
- strftime: Displays a date/time string in a specified format.
- rfc: A modifier specifically for use with strftime, as the format.
- now: A modifier specifically for use with strftime, as the object.
- - Debug, similar to :debug set from Petal::Utils.
- dump: modifier spits out the .perl representation of the object.
- what: modifier spits out the class name of the object.
+ * Text, same as the :text set from Petal::Utils
+
+ * lc: make the string lowercase.
+ * uc: make the string uppercase.
+ * ucfirst: make the first letter of the string uppercase.
+ * substr: extract a portion of the string.
+ * printf: format a string or object in a specified way.
+
+ * List, similar to the :list set from Petal::Utils.
+
+ * group: turns a flat Array into a nested Array, where each inner
+ Array has a set number of elements in it.
+ * sort: sort the array using the default sort algorithm.
+ * limit: only return the first number of items from the list.
+ * shuffle: shuffle the list into a random order.
+ * pick: pick a set number of items randomly from the list.
+ * reverse: reverse the contents of the list.
+
+ * Date, similar to the :date set from Petal::Utils, using on DateTime::Utils
+
+ * date: Builds a DateTime object using specified paramters.
+ * time: Builds a DateTime object from a Unix epoch.
+ * strftime: Displays a date/time string in a specified format.
+ * rfc: A modifier specifically for use with strftime, as the format.
+ * now: A modifier specifically for use with strftime, as the object.
+
+ * Debug, similar to :debug set from Petal::Utils.
+
+ * dump: modifier spits out the .perl representation of the object.
+ * what: modifier spits out the class name of the object.
In addition, the following sets are planned for inclusion very soon:
- - Logic, similar to the :logic set from Petal::Utils
- - Hash, same as the :hash set from Petal::Utils
+ * Logic, similar to the :logic set from Petal::Utils
+ * Hash, same as the :hash set from Petal::Utils
The syntax for the Flower::TAL plugins is based on the modifiers from
Petal::Utils, but extended to use the Flower-specific extensions (the
@@ -125,14 +122,16 @@ The URI set from Petal::Utils is not planned for inclusion,
feel free to write it if you need it.
I'm sure new exciting libraries will be made adding onto these.
-=== Author ===
+## Requirements
+
+ * [Exemel](http://github.com/supernovus/exemel/)
+ * [DateTime::Utils](http://github.com/supernovus/temporal-utils/)
+
+## Author
-Timothy Totten
-http://huri.net/
-http://github.com/supernovus/
+Timothy Totten, supernovus on #perl6, https://github.com/supernovus/
-=== License ===
+## License
-Artistic License 2.0
-http://www.perlfoundation.org/artistic_license_2_0
+[Artistic License 2.0](http://www.perlfoundation.org/artistic_license_2_0)
View
22 lib/Flower.pm6
@@ -1,6 +1,6 @@
class Flower;
-use Exemel;
+use XML;
## Override find with a subroutine that can find templates based off
## of whatever your needs are (multiple roots, extensions, etc.)
@@ -47,8 +47,8 @@ method !get-plugin ($plugin) {
return $object;
}
-## The main method to parse a template. Expects an Exemel::Document.
-multi method parse (Exemel::Document $template, *%data) {
+## The main method to parse a template. Expects an XML::Document.
+multi method parse (XML::Document $template, *%data) {
## First we need to set the data, for later re-use.
%.data = %data;
@@ -62,15 +62,15 @@ multi method parse (Exemel::Document $template, *%data) {
return $template;
}
-## Parse a template in Exemel::Element form.
-multi method parse (Exemel::Element $template, *%data) {
- my $document = Exemel::Document.new(:root($template));
+## Parse a template in XML::Element form.
+multi method parse (XML::Element $template, *%data) {
+ my $document = XML::Document.new($template);
return self.parse($document, |%data);
}
## Parse a template that is passed as XML text.
multi method parse (Stringy $template, *%data) {
- my $document = Exemel::Document.parse($template);
+ my $document = XML::Document.new($template);
if ($document) {
return self.parse($document, |%data);
}
@@ -80,7 +80,7 @@ multi method parse (Stringy $template, *%data) {
method parse-file ($filename, *%data) {
my $file = $.find.($filename);
if $file {
- my $template = Exemel::Document.parse(slurp($file));
+ my $template = XML::Document.load($file);
if $template {
return self.parse($template, |%data);
}
@@ -95,7 +95,7 @@ method parse-elements ($xml is rw, $custom-parser?) {
loop (my $i=0; True; $i++) {
if $i == $xml.nodes.elems { last; }
my $element = $xml.nodes[$i];
- if $element !~~ Exemel::Element { next; } # skip non-elements.
+ if $element !~~ XML::Element { next; } # skip non-elements.
@.elements.unshift: $element; ## Stuff the newest element into place.
if ($custom-parser) {
$custom-parser($element, $custom-parser);
@@ -175,12 +175,12 @@ method parse-element($element is rw, :$safe) {
$plugin."$meth"($element, $fullname);
}
}
- if $element !~~ Exemel::Element { last; } ## skip if we changed type.
+ if $element !~~ XML::Element { last; } ## skip if we changed type.
} ## /for $plugin.handlers
} ## /for @.plugins
## Okay, now we parse child elements.
- if $element ~~ Exemel::Element {
+ if $element ~~ XML::Element {
self.parse-elements($element);
}
}
View
16 lib/Flower/TAL/METAL.pm6
@@ -3,7 +3,7 @@ class Flower::TAL::METAL; # does Flower::Lang;
## The METAL XML Application Language.
-use Exemel;
+use XML;
has $.default-tag = 'metal';
has $.ns = 'http://xml.zope.org/namespaces/metal';
@@ -45,7 +45,7 @@ method load-xml-file ($filename) {
my $file = $.flower.find.($filename);
if ($file) {
- my $xml = Exemel::Document.parse(slurp($file));
+ my $xml = XML::Document.load($file);
%.file{$filename} = $xml;
return $xml;
}
@@ -56,7 +56,7 @@ method load-xml-file ($filename) {
method parse-define ($xml is rw, $tag) {
my $macro = $xml.attribs{$tag};
$xml.unset: $tag;
- my $section = $xml.deep-clone;
+ my $section = $xml.cloneNode;
%!metal{$macro} = $section;
#say "## Saved macro '$macro': $section";
}
@@ -71,7 +71,7 @@ method parse-use ($xml is rw, $tag) {
my @slots = $xml.elements(|%params);
my $found = False;
if %!metal.exists($macro) {
- $xml = %!metal{$macro}.deep-clone;
+ $xml = %!metal{$macro}.cloneNode;
$found = True;
}
else {
@@ -87,9 +87,9 @@ method parse-use ($xml is rw, $tag) {
};
my @macros = $include.root.elements(|%search);
if (@macros.elems > 0) {
- $xml = @macros[0].deep-clone;
+ $xml = @macros[0].cloneNode;
$xml.unset: $defmacro;
- %!metal{$macro} = $xml.deep-clone;
+ %!metal{$macro} = $xml.cloneNode;
$found = True;
}
}
@@ -117,14 +117,14 @@ method use-macro-slots (@slots, $xml is rw, $parser) {
$xml.unset: $defslot;
for @slots -> $slot {
if $slot.attribs{$fillslot} eq $slotid {
- $xml = $slot.deep-clone;
+ $xml = $slot.cloneNode;
$xml.unset: $fillslot;
last;
}
}
}
## Now let's parse any child elements.
- if $xml ~~ Exemel::Element {
+ if $xml ~~ XML::Element {
$.flower.parse-elements($xml, $parser);
}
}
View
4 lib/Flower/TAL/Repeat.pm6
@@ -20,8 +20,10 @@ method lt ($num) { $.number < $num }
method gt ($num) { $.number > $num }
method eq ($num) { $.number == $num }
method ne ($num) { $.number != $num }
+method gte ($num) { $.number >= $num }
+method lte ($num) { $.number <= $num }
## Versions of every and skip that also match on start.
method repeat-every ($num) { $.start || $.every($num) }
-method repeat-skip ($num) { $.start || $.every($num) }
+method repeat-skip ($num) { $.start || $.skip($num) }
View
6 lib/Flower/TAL/TAL.pm6
@@ -3,7 +3,7 @@ class Flower::TAL::TAL; #does Flower::Lang;
## The TAL XML Application Language
-use Exemel;
+use XML;
use Flower::TAL::TALES; ## The TALES attribute sub-language.
use Flower::TAL::Repeat; ## A class representing our repeat object.
@@ -118,11 +118,11 @@ method parse-repeat ($xml is rw, $tag) {
my @elements;
my $count = 0;
for @($array) -> $item {
- my $newxml = $xml.deep-clone;
+ my $newxml = $xml.cloneNode;
$.flower.data{$attrib} = $item;
my $repeat = Flower::TAL::Repeat.new(:index($count), :length($array.elems));
$.flower.data<repeat>{$attrib} = $repeat;
- my $wrapper = Exemel::Element.new(:nodes(($newxml)));
+ my $wrapper = XML::Element.new(:nodes(($newxml)));
$.flower.parse-elements($wrapper);
@elements.push: @($wrapper.nodes);
$count++;
View
12 lib/Flower/TAL/TALES.pm6
@@ -1,6 +1,6 @@
class Flower::TAL::TALES; ## Parses TALES strings, used by TAL.
-use Exemel;
+use XML;
use Flower::TAL::TALES::Default; ## The default TALES parsers.
has @!plugins; ## Our private list of plugins. Use add-plugin() to add more.
@@ -10,7 +10,7 @@ has $.flower; ## The top-most Flower object.
our submethod BUILD (:$parent) {
$!parent = $parent;
$!flower = $parent.flower;
- my $default = Flower::TAL::TALES::Default.new(:tales(self), :$.flower);
+ my $default = Flower::TAL::TALES::Default.new(:tales(self), :$!flower);
@!plugins = $default;
}
@@ -96,16 +96,16 @@ method process-query($data is copy, :$forcexml, :$noxml, :$noescape, :$bool) {
$data.=subst('>', '&gt;', :g);
$data.=subst('"', '&quot;', :g);
}
- ## Default rule for forcexml converts non-XML objects into Exemel::Text.
+ ## Default rule for forcexml converts non-XML objects into XML::Text.
if ($forcexml) {
if ($data ~~ Array) {
for @($data) -> $elm is rw {
- if $elm !~~ Exemel { $elm = Exemel::Text.new(:text(~$elm)); }
+ if $elm !~~ XML { $elm = XML::Text.new(:text(~$elm)); }
}
return $data;
}
- elsif ($data !~~ Exemel) {
- return Exemel::Text.new(:text(~$data));
+ elsif ($data !~~ XML) {
+ return XML::Text.new(:text(~$data));
}
}
elsif ($noxml && $data !~~ Str|Numeric) {
View
2  t/01-basics.t
@@ -1,6 +1,6 @@
#!/usr/bin/env perl6
-BEGIN { @*INC.unshift: './lib' }
+BEGIN { @*INC.push: './lib' }
use Test;
use Flower::TAL;
View
2  t/02-repeat.t
@@ -1,6 +1,6 @@
#!/usr/bin/env perl6
-BEGIN { @*INC.unshift: './lib' }
+BEGIN { @*INC.push: './lib' }
use Test;
use Flower::TAL;
View
2  t/03-default.t
@@ -1,6 +1,6 @@
#!/usr/bin/env perl6
-BEGIN { @*INC.unshift: './lib' }
+BEGIN { @*INC.push: './lib' }
use Test;
use Flower::TAL;
View
2  t/03-escape.t
@@ -1,6 +1,6 @@
#!/usr/bin/env perl6
-BEGIN { @*INC.unshift: './lib' }
+BEGIN { @*INC.push: './lib' }
use Test;
use Flower::TAL;
View
2  t/03-methods.t
@@ -1,6 +1,6 @@
#!/usr/bin/env perl6
-BEGIN { @*INC.unshift: './lib' }
+BEGIN { @*INC.push: './lib' }
use Test;
use Flower::TAL;
View
2  t/05-custom-modifiers.t
@@ -5,7 +5,7 @@
## for all modifiers in the DefaultModifiers set.
BEGIN {
- @*INC.unshift: './lib'; ## Standard lib.
+ @*INC.push: './lib'; ## Standard lib.
@*INC.unshift: './t/lib'; ## Test libraries.
}
View
2  t/06-utils-date.t
@@ -1,6 +1,6 @@
#!/usr/bin/env perl6
-BEGIN { @*INC.unshift: './lib' }
+BEGIN { @*INC.push: './lib' }
use Test;
use Flower::TAL;
View
2  t/06-utils-debug.t
@@ -1,6 +1,6 @@
#!/usr/bin/env perl6
-BEGIN { @*INC.unshift: './lib' }
+BEGIN { @*INC.push: './lib' }
use Test;
use Flower::TAL;
View
3  t/06-utils-list.t
@@ -1,10 +1,9 @@
#!/usr/bin/env perl6
-BEGIN { @*INC.unshift: './lib' }
+BEGIN { @*INC.push: './lib' }
use Test;
use Flower::TAL;
-use Exemel;
plan 7;
View
2  t/06-utils-text.t
@@ -1,6 +1,6 @@
#!/usr/bin/env perl6
-BEGIN { @*INC.unshift: './lib' }
+BEGIN { @*INC.push: './lib' }
use Test;
use Flower::TAL;
View
2  t/07-metal.t
@@ -1,6 +1,6 @@
#!/usr/bin/env perl6
-BEGIN { @*INC.unshift: './blib', './lib' }
+BEGIN { @*INC.push: './blib', './lib' }
use Test;
use Flower::TAL;
Please sign in to comment.
Something went wrong with that request. Please try again.