Embeded Perl Code API
Begaining with Auctionawy 2012 version 15.00 a new API integration tools implemended.
The new version API includes Widgets, Gadgets, Embeded Perl code, new templates tags, new template parsing etc. Embeding Perl code inside html templates and widgets ===================================
Imagine now you can write Perl code direct inside the html templates (views) and widgets. The embeded Perl code will run within the application context so you have direct access to all the application database connection, all global variables and functions, access to your entire server allowed resources, you embed Perl code as you write any Perl script and the Embeded Perl parser will run this perl code snippet and will capture its output and insert it in the place holder specified by the code. Embeded Perl code is inserted inside templates and widgets in this format:
To skip a block, put ! in front of it like that !
Gadgets Output =========== All gadgets output must be printed to the stdout with the regular print function. This output will
be captured by displayed at the same location in the templates. Do Not Return values from the gadgets as these values will be ignored, to display anything you have to print it to the stdout. Since your embeded code will run in the application context then all the application functions and
modules can be called and used. Simple Example
=========== A simple example for embeded Perl code, say you want to display a message with the current logged in username, Here is the code that you use inside the templates or widgets: [perl::]
if ($Global{UserID} ne "") { print "Hello " . $Global{UserID};
}
else {
print "welcome guest, please signin or register now";
}
[::perl]
Now the output will be displayed in the same place and all this perl code will be removed from the output html code.You can write any code short or long simple or complex the embeded parser will grap anything between the
tags. If your Perl code has any errors the program will not exist and will display the error messge received
for you to debug and fix your code.
|