<html>
<head>
<title>Templates: INLINE/INPERL and INLUDE</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body bgcolor="#FFFFFF" text="#000000" link="#3300CC" vlink="#3300CC" alink="#3300CC" leftmargin="10" topmargin="5" marginwidth="10" marginheight="5">
<table width="100%" border="0" cellspacing="3" cellpadding="3" background="bgimage.jpg">
<tr> <td bordercolor="#0000FF"> <p align="center"><font face="Times New Roman, Times, serif" size="4"><b><font size="3" face="Verdana, Arial, Helvetica, sans-serif" color="#000000">WebTools
Templates:<font color="#0000CC"> Page 2</font></font></b></font> </p>
<p><font size="2" face="Verdana, Arial, Helvetica, sans-serif"><b><font face="Courier New, Courier, mono" size="4" color="#000000">3.
INLINE/INPERL templates: Description and reference </font><br>
<br>
WebTools has unique capability to manage templates with build-in
functions (INLINE/INPERL), also it has "xreader" module that
can be used directly in your WebTools scripts. With out any doubts, "templates"
are realy important part of WebTools, so this doucument intend to be comprehensive
source to learn how to work with it!<br>
<br>
Generally INLINE/INPERL templates have exactly same
functions as normal xreader has! But INLINE/INPERL templates are more
comfortable and easer to use.<br>
<br>
NOTE 1: I want to make one stipulation: INLINE and INPERL terms mean and
do absolutly same things, but INPERL is used in Perl code and INLINE is
used only in HTML code! From now on I will use term INLINE instead of
INLINE/INPERL. <br>
<br>
NOTE 2: There is small difference between INLINE and INPERL. Result of
INLINE template will be pushed directly into HTML code, where template
itself exist! From another hand INPERL return it's result into default
variable <font color="#FF0000">$_</font> Please keep this in your mind!<br>
<br>
INLINE syntax:<br>
<br>
<br>
<font color="#0000CC"><!--<font color="#006633">©</font>INLINE<font color="#006633">©</font>>
inline functions </<font color="#006633">©</font>INLINE<font color="#006633">©</font>--></font><br>
<br>
OR <br>
<br>
<font color="#0000CC"><!--<font color="#006633">©</font>INPERL<font color="#006633">©</font>>
inline functions </<font color="#006633">©</font>INPERL<font color="#006633">©</font>-->
<br>
</font><br>
<font color="#FF0066"> If you want use alternative style of
INILINE/INPERL:<br>
</font><br>
<font color="#0000CC">%%%INLINE%%% inline functions %%%/INLINE%%%</font><br>
<br>
OR <br>
<br>
<font size="2" face="Verdana, Arial, Helvetica, sans-serif"><b><font color="#0000CC"> %%%INPERL%%%
inline functions %%%/INPERL%%%</font></b></font><font color="#0000CC"><br>
</font><br>
<br>
<!--©INLINE©></©INLINE©--> is used
to excape HTML (and repectively PERL code), so code between these "tags"
will be parsed from WebTools engine.<br>
<br>
Supported inline functions are:<br>
<br>
<font color="#0000CC"><<font color="#006633">§</font>TEMPLATE<font color="#FF0000">:</font>number_of_templates_variable<font color="#FF0000">:</font>$variable<font color="#FF0000">:</font><font color="#006633">§</font>>
<br>
<br>
<XREADER<font color="#FF0000">:</font>number_of_template_in_file<font color="#FF0000">:</font>template_file.jhtml<font color="#FF0000">:</font>$first_param,$second_param,...><br>
<br>
<S<font color="#006633">©</font>L<font color="#FF0000">:</font>number_of_SQL_query<font color="#FF0000">:</font>"SQL
query;"<font color="#FF0000">:</font>used_query<font color="#FF0000">:</font>row_number<font color="#FF0000">:</font>col_number<font color="#FF0000">:</font>should_be_printed?<font color="#FF0000">:</font>S<font color="#006633">©</font>L><br>
<br>
<S<font color="#006633">©</font>LVAR<font color="#FF0000">:</font>number_of_template_variable<font color="#FF0000">:</font>S<font color="#006633">©</font>L><br>
<br>
<MENUSELECT<font color="#FF0000">:</font>$html_source<font color="#FF0000">:</font>"SQL
query"<font color="#FF0000">:</font>$ref_DB<font color="#FF0000">:</font>$ref_TEMPLATE<font color="#FF0000">:</font>$ref_HTML<font color="#FF0000">:</font>$dbh<font color="#FF0000">:</font>>
<br>
</font><br>
<font color="#0000CC"><font color="#FF0066"> If prefer you can use
alternative syntax for all templates!</font></font><br>
<br>
Supported inline functions with alternative syntax (in any
other aspect they are same):<br>
<br>
<font color="#0000CC">%%TEMPLATE<font color="#FF0000">:</font>number_of_templates_variable<font color="#FF0000">:</font>$variable<font color="#FF0000">:</font>%%<br>
<br>
%%XREADER<font color="#FF0000">:</font>number_of_template_in_file<font color="#FF0000">:</font>template_file.jhtml<font color="#FF0000">:</font>$first_param,$second_param,...%%<br>
<br>
%%SQL<font color="#FF0000">:</font>number_of_SQL_query<font color="#FF0000">:</font>"SQL
query;"<font color="#FF0000">:</font>used_query<font color="#FF0000">:</font>row_number<font color="#FF0000">:</font>col_number<font color="#FF0000">:</font>should_be_printed?<font color="#FF0000">:</font>SQL%%<br>
<br>
%%SQLVAR<font color="#FF0000">:</font>number_of_template_variable%%<br>
<br>
%%MENUSELECT<font color="#FF0000">:</font>$html_source<font color="#FF0000">:</font>"SQL
query"<font color="#FF0000">:</font>$ref_DB<font color="#FF0000">:</font>$ref_TEMPLATE<font color="#FF0000">:</font>$ref_HTML<font color="#FF0000">:</font>$dbh<font color="#FF0000">:</font>%%<br>
</font><br>
I don't like to make analogy between "normal" templates described
in previuos page because thay practicaly is absolutely equal. I just think
to show you an example that will help you to understand difference.<br>
<br>
At last I forgot to introduce new feature that will be useful. This "function"
include file in your perl/html file independ of it's contain (it can be
perl code or html... no matter!)<br>
INCLUDE syntax:<br>
<br>
<font color="#993366"><b><font size="2" face="Verdana, Arial, Helvetica, sans-serif"> <!--<font color="#0000FF">©</font>INCLUDE<font color="#0000FF">©</font>file.ext<font color="#0000FF">©</font>--></font></b></font><br>
<br>
or alternative syntaxes:<br>
<br>
<font color="#993366"><b><font size="2" face="Verdana, Arial, Helvetica, sans-serif"> <!--<font color="#0000FF">%</font>INCLUDE<font color="#0000FF">%</font>file.ext<font color="#0000FF">%</font>--></font></b></font><br>
<br>
OR<br>
<br>
<font color="#993366"><b><font size="2" face="Verdana, Arial, Helvetica, sans-serif"> <font color="#0000FF">%%%</font>INCLUDE<font color="#0000FF">%</font>file.ext<font color="#0000FF">%%%</font></font></b></font>
<br>
<br>
Note that you should not use INLINE/INPERL tag for that function!!! (For
more info see example below)<br>
<br>
<FONT SIZE="3">To see full description of INLINE/INPERL syntax and comparison
between them and "normal" templates click <A HREF="syncomp.html"><FONT SIZE="2">HERE</FONT></A>.</FONT><BR>
<br>
<font face="Courier New, Courier, mono" size="4" color="#000000"><a name="example"></a>4.
INLINE/INPERL templates: How to use it?</font><br>
<br>
All INLINE and INPERL templates are located in our pretty perl/html (as
we use to refer to them: WebTools perl code) without care whether
database is connected or not! WebTools will care about evry insignificant
detail in this form of templates. Just watch out!<br>
<br>
</b></font><font color="#000000"><b><font size="2" face="Verdana, Arial, Helvetica, sans-serif">-----
Please save this file as: jhtml/inline.jhtml but remove this line -----<br>
<font color="#993366">Any information here is comment till begining separator<br>
<©N®1®1®®©><br>
<BR>Are you male? <input type="radio" name="Male"
value="Y" <§TEMPLATE:1§>>Yes<br>
<input type="radio" name="Male" value="N"
<§TEMPLATE:2§>>No<br>
<input type="radio" name="Male" value="-"
<§TEMPLATE:3§>>Unknown :-)</font></font></b></font><font color="#993366"><b><font size="2" face="Verdana, Arial, Helvetica, sans-serif"><br>
<˜©˜><br>
</font></b></font><b><font size="2" face="Verdana, Arial, Helvetica, sans-serif">-----
This is end of file. Please remove this line -----<br>
</font></b><b><font color="#000000" size="2" face="Verdana, Arial, Helvetica, sans-serif"><br>
</font><font color="#000000"><b><font size="2" face="Verdana, Arial, Helvetica, sans-serif">-----
Please save this file as: htmls/include.whtml but remove this line -----<br>
</font></b></font><b><font size="2" face="Verdana, Arial, Helvetica, sans-serif" color="#993366">$color
= 'red';</font><font size="2" face="Verdana, Arial, Helvetica, sans-serif"><br>
----- This is end of file. Please remove this line -----</font></b><font color="#000000" size="2" face="Verdana, Arial, Helvetica, sans-serif">
<br>
<br>
</font><font color="#000000"><b><font size="2" face="Verdana, Arial, Helvetica, sans-serif">-----
Please save this file as: htmls/inline.whtml but remove this line -----<br>
</font></b></font><font color="#993366"><b><font size="2" face="Verdana, Arial, Helvetica, sans-serif"><!--
PERL: Hide Perl`s script<br>
<?perl <br>
Header(type=>'content',val=>'text/html; charset=Windows-1251');<br>
<!--©INCLUDE©include.whtml©--> # That will include
file with color definitions!<br>
?><br>
//--><br>
<HTML><br>
<HEAD><br>
<TITLE>INLINE Example</TITLE><br>
</HEAD><br>
<BODY TEXT="white" BGCOLOR="black" LINK="red"<br>
VLINK="</font><font color="#993366"><b><font size="2" face="Verdana, Arial, Helvetica, sans-serif"><!--©INLINE©></font></b></font><font size="2" face="Verdana, Arial, Helvetica, sans-serif"><b><§TEMPLATE:7:$color:§><font color="#993366"><b><font size="2" face="Verdana, Arial, Helvetica, sans-serif"></©INLINE©--></font></b></font></b>"><br>
<FONT FACE="Verdana" SIZE=2><B><br>
<?perl<br>
print "Example begin!<BR>\n";<br>
<b> <!--©INPERL©><XREADER:1:inline.jhtml:></b><b></©INPERL©--></b><br>
$source = $_; # Result is in $_ !!!<br>
@DB_VALUES = ("Y","N","-");
#Possible values that SQL can return!<br>
@TEMPLATE_NUMBERS = (1,2,3); #Number of templates in
HTML<br>
@HTML_VALUES = ("checked",""); #Possible
states of "check box" tag!<br>
$ref1=\@DB_VALUES; #We need references to these arrays!<br>
$ref2=\@TEMPLATE_NUMBERS;<br>
$ref3=\@HTML_VALUES;<br>
# $sqlq = "SELECT menuState FROM menu_table WHERE
menu= 'gender';";<br>
$sqlq = "!Y"; # That should be SQL query but
we put "!" in the begining<br>
# so we simulate query that select "Y" state!</font></b></font></b><b><font color="#993366"><b><font size="2" face="Verdana, Arial, Helvetica, sans-serif"><br>
$dbh = undef; #If DB handler is invalid, WebTools will
connect DB for you!<br>
?><br>
</B>Also see state of check box:<BR><br>
<!--©INLINE©><MENUSELECT:$source:$sqlq:$ref1:$ref2:$ref3:$dbh:></©INLINE©--><br>
<BR> My work possition is:<br>
</font><font color="#993366"><b><font size="2" face="Verdana, Arial, Helvetica, sans-serif"><!--©INLINE©><S©L:1:"select
USER from webtools_users where id=0;":1:1:1:1:S©L></©INLINE©--></font></b></font><font size="2" face="Verdana, Arial, Helvetica, sans-serif"><br>
</FONT><br>
</BODY><br>
</HTML><br>
</font></b></font><b><font size="2" face="Verdana, Arial, Helvetica, sans-serif">-----
This is end of file. Please remove this line -----</font></b><font color="#000000" size="2" face="Verdana, Arial, Helvetica, sans-serif"><br>
<br>
To run this script please save and upload these files in your webtools
directory (in jhtml and htmls), open one browser and write there follow
url:<br>
<br>
<font color="#CC0000">http://your_server/cgi-bin/your_webtools/process.cgi?file=inline.whtml</font><br>
<br>
where: <i><font color="#CC0000">your_server</font> </i>is host where you
keep WebTools and where you can run CGI scripts,<br>
<i><font color="#FF0000">your_webtools</font></i>
is directory where you keep WebTools files.</font></b><font size="2" face="Verdana, Arial, Helvetica, sans-serif"><b>
</b></font></p>
<p align="left"><b><font size="2" face="Verdana, Arial, Helvetica, sans-serif"> I
hope everything works fine, but please learn evry line of this code and try to
explain for you how it works :-)<br> <br> Best regards!<br> <br> <a href="http://www.proscriptum.com/">www.proscriptum.com
</a><br> <br> Author: Julian Lishev (<a href="mailto:julian@proscriptum.com">julian@proscriptum.com</a>)<br>
</font></b></p></td></tr> </table>
</body>
</html>