HTP

Source code: ref/tutorial.htp

Table of Contents
  htp.def
  macros.def
  htp.htt

<BLOCK body>

<H1>The Tutorial</H1>

<p> This tutorial should help you with the first steps in htp.  This
tutorial assumes that you are already somewhat familiar with HTML.
You can find good HTML tutorials on the web, e.g. at the <a
href="http://www.w3schools.com/">
W3Schools</a>. If you speak
german, spanish, french or japanese, you should take a look at <a
href="http://www.selfhtml.org/">
SELFHTML</a>.
</p>

<p> 
On this and the following pages we want to give you an idea of
how htp is used.  If you read this the first time you should
<em>not</em> follow the links to the <manlink href=".">reference
manual</manlink>.
</p>


<H2>Writing simple htp files</H2>

<p>
In their simplest form htp files are just ordinary html files.  In
that case the htp process just copies the file.  However, there are
some features of htp makes live easier in many cases.  Let's have a
look at a simple example:
</p>

<htpcode file="tut/tut1.htp" linenr>
<set author="Joe Doe">
<set email="webmaster@domain.com">

<html>
<head>
  <meta name="author" content="$author">
  <title>My first htp page</title>
</head>
<body>
This page was produced by htp.
<hr>
Copyright by <use author>,
<a href="mailto:$email"><use email></a>,
last updated <file date>
</body>
</htpcode>

<p> You can download the file <a href="tut/tut1.htp">tut1.htp</a> and
put it into an empty directory.  Then you can invoke htp from the
command line (e.g. from the DOS box) like this:

<PRE>
htp tut1.htp tut1.html
</PRE>

This creates a file <a href="tut/tut1.html">tut1.html</a>, your first
html file produced by htp.
</p>

<p> In line 1 we use a special tag named <manlink
href="set.html">
<code>set</code></manlink>.  Even though this looks
like a html tag it is really a htp tag.  htp reads this but it doesn't
copy it over in the html file.  Instead it defines the macro
<code>author</code> and bind the value <code>Joe Doe</code> to it.
This macro is later expanded in line 6 and line 12, to retrieve the
author name again.  </p>

<p>
The advantage of using macros is obvious if you consider the email
macro in line 2 and 13.  Normally you need to type the email twice,
once in the <code>href</code> attribute and once to show up on the
page.  If you have a typo in the <code>href</code> tag you probably
won't notice it.  With the use of macros you only have to type the email
once.  Also you have to update only one place when your email address
changes.
</p>

<p> As you can see there are two ways to get the value, which is bound
to a macro: One is the <manlink
href="use.html">
<code>use</code></manlink> tag in line 12.  This tag
is replaced by htp with the contents of the macro, <code>Joe
Doe</code> in this case.  However, if the macro needs to be expanded
inside an html or htp tag, you can't nest a <manlink
href="use.html">
<code>use</code></manlink> tag.  Instead the "$"
character followed by the macro name can be used as shown in lines 6
and 13. </p>

<p> In line 14 you can see another special htp tag, the <manlink
href="file.html">
<code>file</code></manlink> tag.  This tag has many
functions, however, in this case it is just used to get the
modification date of the current htp file.  </p>

<p> 
In the next section of this tutorial we show you how to use htp in
big projects where you have many web pages that should get a
similar layout.
</p>

<p><a href="include.html">Go to the next section</a></p>

</BLOCK>

  page source
  htp project
  htp homepage
hosted by
SourceForge.net
HTML coding Powered by htp
htp on-line reference / http://htp.sourceforge.net/ref/
Authors: Jim Nelson, Jochen Hoenicke, Michael Möller.
Maintainers: Jochen Hoenicke.

Copyright © 1995-96 Jim Nelson.
Copyright © 2001-2003 Jochen Hoenicke.
Permission to reproduce and distribute this hypertext document granted according to terms described in the License section.

last updated Tue Feb 22, 2011