Embperl - building dynamic websites with Perl


Basic Example
[ << Prev: Execute ] [ Content ] [ Next: Example for using method calls >> ]

With the following setup:

 <Location /foo>
    PerlSetEnv EMBPERL_OBJECT_BASE base.htm
    PerlSetEnv EMBPERL_FILESMATCH "\.htm.?|\.epl$"
    SetHandler perl-script
    PerlHandler Embperl::Object 
    Options ExecCGI
 </Location>

Directory Layout:

 /foo/base.htm
 /foo/head.htm
 /foo/foot.htm
 /foo/page1.htm
 /foo/sub/head.htm
 /foo/sub/page2.htm

/foo/base.htm:

 <html>
 <head>
 <title>Example</title>
 </head>
 <body>
 [- Execute ('head.htm') -]
 [- Execute ('*') -]
 [- Execute ('foot.htm') -]
 </body>
 </html>

/foo/head.htm:

 <h1>head from foo</h1>

/foo/sub/head.htm:

 <h1>another head from sub</h1>

/foo/foot.htm:

 <hr> Footer <hr>

/foo/page1.htm:

 PAGE 1

/foo/sub/page2.htm:

 PAGE 2

/foo/sub/index.htm:

 Index of /foo/sub

If you now request http://host/foo/page1.htm you will get the following page

  
 <html>
 <head>
 <title>Example</title>
 </head>
 <body>
 <h1>head from foo</h1>
 PAGE 1
 <hr> Footer <hr>
 </body>
 </html>

If you now request http://host/foo/sub/page2.htm you will get the following page

  
 <html>
 <head>
 <title>Example</title>
 </head>
 <body>
 <h1>another head from sub</h1>
 PAGE 2
 <hr> Footer <hr>
 </body>
 </html>

If you now request http://host/foo/sub/ you will get the following page

  
 <html>
 <head>
 <title>Example</title>
 </head>
 <body>
 <h1>another head from sub</h1>
 Index of /foo/sub
 <hr> Footer <hr>
 </body>
 </html>

 

[ << Prev: Execute ] [ Content ] [ Next: Example for using method calls >> ]


© 1997-2023 Gerald Richter / actevy