It is not a Perl's functions library. (Although it may be used as such)
It is not a programming language. (Although it seems)
It is a system of templates and replacement of variables for the Web and Perl. It manages web components, pages, URLs, graphics, HTML tags, as objects.
It is a way to separate Perl code and HTML. The HTML Tags are replaced by variables created in Perl.
Separation between Perl code and HTML.
Simplicity, not many things to learn about Perl. Objetive is that Nes has not more of twenty Tags, and only one object to created in Perl.
Reuse Code, encapsulating HTML with your Perl code.
CGI distinguishes scripts running on server side and scripts running on client side. For a Web server is not same a file called "file.cgi" and other called "file.html"
This distinction is good for a Web Server, but not for a Web user, who know nothing about that.
Sometimes we access to information in this way:
http://domain.com/file.cgiAnd other times we useĀ:
http://domain.com/file.html
If you ask to Web Server, CGI is the reason, and if you ask to an user, may be that you will create a problem to he.
With simple instructions into file "htaccess" we can create a handler and we can run the perl scripts with the extension that we want.
For Nes we are created extension nhtml (nes-html), htmaccess file seens as follow:
AddHandler perl-nes .nhtml AddHandler perl-nes .nhtm Action perl-nes /nes/dispatch.cgi
Well and, what is the way to know the script to run for a certain html file?
Nes uses next Tag to be included at the fist line of HTML file:
{: NES 0.4 ('file.cgi') :} <html> <head> ...
"dispatch.cgi" will launch "file.cgi", but...
What is required on "file.cgi" to put things on "file.nhtml"?
If we put nothing Nes will launch thew file as a HTML, but for the other cases we only need five simple lines of Perl code:
# fundamental :-) use Nes; # Create a objet of class Singleton. my $nes = Nes::Singleton->new('file.nhtml'); # variable to store data which we will show on HTML my $nes_tags = {}; # data to be send to HTML output $nes_tags->{'variable'} = 'Things to say to world'; # sending data to HTML output $nes->out(%$nes_tags);
How show we this variable on file.nhtml?
With this Tag Nes:
{: NES 0.4 ('file.cgi') :} <html> <head> <title>Nes sample/title> </head> <body> {: $ variable :} </body> </html>
doing http://domain.com/file.nhtml we will have:
Things to say to world