Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re^24: aXML vs TT2

by Logicus (Initiate)
on Oct 23, 2011 at 06:47 UTC ( [id://933165]=note: print w/replies, xml ) Need Help??


in reply to Re^23: aXML vs TT2
in thread aXML vs TT2

I think it was solution 2 where I described it, but in a nutshell, that tag would take a path to a file which contains the string to be literally output, load it into memory and return a position marking token to the document. At the post processing stage immediately prior to exit that token would then be replaced with the value from memory.

Replies are listed 'Best First'.
Re^25: aXML vs TT2
by ikegami (Patriarch) on Oct 23, 2011 at 06:58 UTC
    I don't know how to create a post-include type plugin -- well any plugin, really -- but could "lt" be one of them?

      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.

        Wait, that means a plugin can't safely return "<" because it might end up calling another plugin it knows nothing about!!!

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://933165]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (8)
As of 2024-04-18 09:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found