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.


In reply to Re^26: aXML vs TT2 by Logicus
in thread aXML vs TT2 by Logicus

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.