Htmlc: variables expansion. File created the 3rd of March 2003.
This file can be compiled using:
htmlc -I ../../doc_src/Includes/ -env env0 -c example-eng.html
Environment files are lists of bindings. A binding defines a name
(``an identifier'') to a constant value. A constant value could be an
integer, a floating point number, a character, a character string, a
boolean (either true
or false
), or a previously
bound identifier.
Lexical conventions for constants and identifiers follow those of the Caml language.
Bindings may have one of the two following syntactic flavors:
let ident = value;;
ident = valueor
ident value
#
and spread to
the end of line.The environment file env0
is free style:
The environment file env1.ml
is Caml style:
So that the Htmlc'c environment variable \$X
is expanded
as $X, and the variable \$Y
as an integer ($Y).
And similarly, the system variable <\$HOME>
is
now found to be the value of the variable \$HOME
in the user's
global environment.
As usual, the hôtel \$hotel is situated at \$hotel_address.
Note that aliases are possible, as the definition of
\$long_def
which is properly bound to the value of
\$a_long_definition_can_spread_on_more_than_one_line
,
which is:
$long_defIn the environment file, we purposedly choose to name the last variable defined
\$last_variable
and it is bound to the value true
:
we can check that its value is effectively ``$last_variable
''.
Note that \$adresse_hotel is :
\$adresse_hotel.
Meaning that the value bound to a variable can refer to the value of
another variable.
As usual, the hôtel $hotel is situated at $hotel_address.
Here, we include the file included-eng.html
.
Here is the beginning of the file included-eng.html
.
Here is the end of the file included-eng.html
.
exec
If command name
is the name of a Unix command accessible
to the compiler, then write
<!--#exec cmd="command name"-->to include the output of the command in your document. For instance, using "ls *.ml", we get the list of
ml
files in the test
directory of the compiler's source:
So for instance, you get the date of compilation with the following line:
<!--#exec cmd="date"-->
fsize
An easy way to have the size of a file is to ask it to the underlying file system, using:
<!--#fsize file="example-eng.html"-->for instance, (the source file of) this file is bytes long.
echo
The command echo
let's you output the value bound to a
variable:
<!--#echo var="\$myvar"-->
set
and define
You can define variables in your document using the command
define
as follows:
<!--#define myvar="myvalue"-->
<!--#define myvar="Pierre Weis, INRIA researcher"-->
<!--#echo var="\$myvar"-->
gives you:
<!--#define myvar_with_quotes="«\$myvar»"-->
<!--#echo var="\$myvar_with_quotes"-->
gives you:
set
, you can bind names to arbitrary values
computed at file expansion timeexec
, you compute the value you want to bind
via set
:
<!--#set thefiles="<!--#exec cmd=\"ls *[eng,fra].html\"-->"-->"-->
\$thefiles
is set to the
list of files in the current working directory that contain
eng
or fra
in their names and have suffix
.html
, at the time of compilation of this very source file. The
value given to \$thefiles
is also obtained by calling
echo
:
<!--#echo var="\$thefiles"-->