Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: How To Use Bootstrap Code in Perl Script?

by tangent (Parson)
on Feb 16, 2016 at 02:37 UTC ( [id://1155319]=note: print w/replies, xml ) Need Help??


in reply to How To Use Bootstrap Code in Perl Script?

You might want to try out using templates for this kind of work as it allows you to separate the HTML from your code. Have a look at HTML::Template and Template Toolkit - the former is probably easier to learn but the latter is very powerful. Using HTML::Template you would create a template file like this:

example.tmpl

<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1 +, maximum-scale=1"> <link type="text/css" rel="stylesheet" href="../hideo/bootstrap/cs +s/bootstrap.min.css"> <!-- etc. fill in rest of head elements --> </head> <body> <!-- RIGHT AFTER <body> TAG --> <script type="text/javascript" src="../hideo/js-plugin/jquery/jque +ry-1.10.2.min.js"></script> <script type="text/javascript" src="../hideo/JQuery/jquery.cycle.a +ll.2.74.js"></script> <!-- this will be replaced --> <TMPL_VAR NAME=CONTENT> <!-- JUST BEFORE </body> TAG --> <script type="text/javascript" src="../hideo/bootstrap/js/bootstra +p.js"></script> <script type="text/javascript" src="../hideo/js/custom.js"></scrip +t> </body> </html>
Then in your perl script you pass the file to the template engine, and populate it with the other content you want on the page:
use HTML::Template; my $file = '/path/to/example.tmpl'; my $template = HTML::Template->new( filename => $file ); # do all the work to create the content my $content = "Start of Content"; # ... # pass content to the template $template->param( CONTENT => $content ); print "Content-Type: text/html\n\n"; print $template->output;

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (5)
As of 2024-03-28 16:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found