in reply to Re^25: aXML vs TT2
in thread aXML vs TT2
Well, it's a special case and the ability is going to need to be coded into the parser itself (like the 4 special char codes). One of the older versions specifically the one currently in use on my sites, has just such a routine built in. I will make sure it's done by the time I put out the first release.
As for making a custom plugin, it's very simple.
Lets say you want to add a plugin called foo which takes two attributes called bar and baz, and some meta data.
In the aXML doc --------------- <foo bar="hello" baz="world"> good to be here </foo> In your sites private subs module --------------------------------- my $plugins = { foo => sub { my $args = $_[0]; #a hashref my $data = $_[1]; #good to be here $args->{'tag_name'}; #foo $args->{'bar'}; #hello $args->{'baz'}; #world #do some stuff with the args and data here return 'some result'; } };
In the case where your plugin does not need to return any value to the document, you can just return '<null>'. This is to prevent the parser from throwing a warning about doing a substitution on an empty string, and is automatically removed from the document in the post processing stage.
Also you could create a plugin called "lt" with the following code:
lt => sub { return '<'; } or lt => sub { '<' } #golfed :P
However it wouldn't achieve anything and would result exactly the same as just putting a < into the document to begin with.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^27: aXML vs TT2
by ikegami (Patriarch) on Oct 23, 2011 at 09:30 UTC | |
by Logicus (Initiate) on Oct 23, 2011 at 10:22 UTC | |
by Corion (Patriarch) on Oct 23, 2011 at 10:33 UTC | |
by Logicus (Initiate) on Oct 23, 2011 at 11:11 UTC | |
by Corion (Patriarch) on Oct 23, 2011 at 11:28 UTC | |
| |
by Anonymous Monk on Oct 23, 2011 at 11:20 UTC | |
| |
by ikegami (Patriarch) on Oct 23, 2011 at 10:41 UTC | |
by Logicus (Initiate) on Oct 23, 2011 at 11:20 UTC | |
by ikegami (Patriarch) on Oct 23, 2011 at 11:40 UTC | |
|