Embperl
view release on metacpan or search on metacpan
intended (unless it's explicitly specified). Try using:
Apache::Include->virtual("test.epl", $r);
(instead of just Apache::Include->virtual("test.epl");
where $r is the apache request rec)
=head2 I can't get PerlSendHeader to work under Embperl?
You don't need PerlSendHeader when using Embperl - Embperl always sends
its own httpd header.
=head2 But how do I customize the header that Embperl is sending?
You'll find the answer to this and many other header issues in
the L<"Common Questions"> section.
=head2 I can't figure out how to split a 'while' statement across
two [- -] segments
That isn't surprising, as you cannot split Perl statements across multiple
[- -] blocks in Embperl :) You need to use a metacommand for that. The [$while$]
metacommand comes to mind... :)
For a list of all possible metacommands, see the section on
L<Meta-Commands|Embperl/"[$ Cmd Arg $] (Meta-Commands)"> in the Embperl documentation.
[$ while $st -> fetch $]
#some html or other Embperl blocks goes here
[$ endwhile $]
Newer Embperl versions (1.2b3 and above) supports the [* *] which can be
used for such purposes.
[* while ($st -> fetch) { *]
#some html or other Embperl blocks goes here
[* } *]
While the later can use all Perl control structures, the first seems to
me more readable and is better debugable, because Embperl controls the
execution of the control structure it can do a quite better job in debug
logging.
=head2 My HTML tags like '<' '>' and '"' are being translated to <, > !!!
Hey! Not you again!? I thought we already sent you to the
L<"Escaping & Unescaping"> section of the FAQ?!?! ;)
=head2 Netscape asks to reload the document
If you have something like this in your source, it may be the problem:
<META HTTP-EQUIV="content-type" CONTENT="text/html;charset=iso-8859-1">
Netscape seems to have a problem in such cases, because the http header is
only content-type text/html, while the META HTTP-EQUIV has an additional
charset specified. If you turn optEarlyHttpHeader off, Embperl will
automatically set the http header to be the same as the META HTTP-EQUIV.
=head2 I get "Stack underflow"
The problem often occurs, when you have a <table> tag in one file and a </table>
tag in another file and you both include them in a main page (e.g. as header
and footer). There are two workarounds for this problem:
=over 4
=item 1. Set optDisableTableScan
This will avoid that Embperl takes any action on tables. You can disable/enable
this (also multiple times) inside the page with
[- $optDisableTableScan = 1 -]
If you put this at the top of your header/footer which you include with Execute,
then the main page will still process dynamic tables.
=item 2. Add a <table> as comment
Add the following to the top of
the footer document:
<!-- <table><tr><td> -->
This will work also, because Embperl (1.x) will not scan for html comments
=back
=head1 Common Questions
The most common questions of all deal with L<"Escaping
& Unescaping"> - they are so common that the whole next section is
devoted to them. Less common questions are addressed here:
=head2 How can I get my HTML files to be converted into Perl code which, as a
whole, could then be compiled as function so that I could, for
instance, fetch Perl docs from the Formatter table and compile them the
way AUTOLOAD does.
Embperl cannot covert your HTML into one piece of Perl-code, but you can
wrap the call to Execute into a Perl function and let AUTOLOAD call it.
=head2 I have an HTML page which is dynamically generated at runtime
and should be post-processed by Embperl. How can I do this?
=over 4
=item 1.) Generate the page within a normal CGI/Apache::Registry script and
put the result into a scalar - then you can call HTML::Embperl::Execute to
( run in 0.898 second using v1.01-cache-2.11-cpan-d7f47b0818f )