Nes
view release on metacpan or search on metacpan
lib/Nes/Singleton.pod view on Meta::CPAN
Nes should be run by calling the template, other methods are
implemented to facilitate debugging.
=head2 out
In the parameter we pass a copy of hash (%$hash) with the data we want
to replace in the template.
my $nes_tags = {};
$nes_tags->{'hello'} = 'Hello World!';
$nes->out(%$nes_tag);
./.
my %nes_tags;
$nes_tags{'hello'} = 'Hello World!';
$nes->out(%nes_tag);
The method 'out' does not exit script or immediately print values,
your script can continue after call to out, but for clarity it is
recommended to include at the end of script.
This will work:
...
$nes->out(%$nes_tag);
&foo($bar);
...
For clarity use this:
...
&foo($bar);
$nes->out(%$nes_tag);
...
=head2 add
Added Tags without sending out. If you template:
{: NES 1.0 ('myscript1.pl','myscript2.pl') :}
If myscript1 and myscript2 defined Tags, mysqcript1 should have:
$nes->add(%tags);
And myscript2:
$nes->out(%tags);
If you call to out method in myscript1, the tags of myscript2 never be replaced.
If you not call to out method in last script, the Tags never be replaced.
The routine use of the add method is in creating plugin.
=head1 .nes.cfg
You .nes.cfg contains:
private_key = pass3
myscript_var1 = 50
Then you can access:
use Nes;
my $nes = Nes::Singleton->new('template.nhtml');
my $config = $nes->{'CFG'};
my $var = $config->{'myscript_var1'};
my $pkey = $config->{'private_key'};
# Global configuration
my $pdir = $config->{'plugin_top_dir'};
=head1 Session
my $nes = Nes::Singleton->new();
my $session = $nes->{'session'};
# Create session:
$session->create($user, $expire);
# Get session:
$user = $session->{'user'};
# Delete session:
$session->del;
=head1 Query
use Nes;
my $nes = Nes::Singleton->new('template.nhtml');
my $query = $nes->{'query'};
my $q = $query->{'q'};
Nes::Singleton->{'query'}->{'q'} is equivalent to do:
use CGI;
my $q = CGI->new;
In addition to GET or POST with Nes::Singleton->{'query'} we pick
parameters of Nes Objects in the following format:
objectname_param_number
For our example the name of the object is lucky.nhtml, the extension
is ignored, then the first parameter:
Nes::Singleton->{'query'}->{'q'}{'lucky_param_1'}
The object name is:
my $obj = Nes::Singleton->{'query'}->{'q'}{'obj_param_0'};
my $par = Nes::Singleton->{'query'}->{'q'}{$obj.'_param_1'};
The following variables are available in .nes.cfg for POST control:
max_post = 512 # Max kB. maximum size of POST.
max_upload = 2048 # Max kB. maximum size of the upload, 0 none
tmp_upload = 512 # In big upload, memory consumption is high,
# this defined from that kB. using a temporary
# file in the upload, preventing these are
# loaded into memory.
# * If tmp_upload is 0 or is greater than max_post,
# max_upload limit will be equal to max_post. Therefore,
# max_upload to take value, tmp_upload to be equal to or
# less than max_post.
For disable uploads, put this in you .nes.cfg:
( run in 0.798 second using v1.01-cache-2.11-cpan-39bf76dae61 )