.\" Automatically generated by Pod::Man 4.10 (Pod::Simple 3.35) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "WML_TUTORIAL 7" .TH WML_TUTORIAL 7 "2021-05-25" "EN Tools" "EN Tools" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" WML Tutorial \- Understanding WML step\-by\-step .SH "DESCRIPTION" .IX Header "DESCRIPTION" This tutorial gives you a step-by-step introduction to the features of \s-1WML,\s0 separated into tiny lessons. Each lesson shows one particular aspect or feature of \s-1WML.\s0 The order of lessons go from easy and trivial to hard and complex. .SH "IMPLICIT MARKUP PROCESSING" .IX Header "IMPLICIT MARKUP PROCESSING" .SS "\s-1LESSON:\s0 Plain Data Throughput" .IX Subsection "LESSON: Plain Data Throughput" In this lesson we first learn that \s-1WML\s0 is 95% of the time transparent to its input, i.e. we can pass through any data without corruption. .PP Input: .PP .Vb 3 \& 1| foo \& 2| \& 3| quux .Ve .PP Output: .PP .Vb 3 \& 1| foo \& 2| \& 3| quux .Ve .PP This is because per default there are neither definitions for symbols \f(CW\*(C`foo\*(C'\fR or \f(CW\*(C`quux\*(C'\fR nor a defined \s-1HTML\s0 tag named \f(CW\*(C`\*(C'\fR. And because there are no unnecessary whitespaces in this example, the input cannot be stripped in any case. .SS "\s-1LESSON:\s0 Protected Markup Code" .IX Subsection "LESSON: Protected Markup Code" Sometimes situations can occur where some of your markup code or page contents conflicts with \s-1WML\s0 due to overlapping tagnames, etc. Here \s-1WML\s0 interprets some stuff you actually don't want to be interpreted. .PP Input: .PP .Vb 2 \& 1| foo: foo.c \& 2| $(CC) \-o foo foo.c .Ve .PP Output: .PP .Vb 2 \& 1| foo: foo.c \& 2| \-o foo foo.c .Ve .PP Here the `\f(CW\*(C`$(CC)\*(C'\fR' was expanded to an empty string because \s-1IPP\s0 uses the same syntax for variable interpolation like \fImake\fR. To avoid this just surround the critical part with the WML-internal \f(CW\*(C`\*(C'\fR container tag. .PP Input: .PP .Vb 2 \& 1| foo: foo.c \& 2| $(CC) \-o foo foo.c .Ve .PP Output: .PP .Vb 2 \& 1| foo: foo.c \& 2| $(CC) \-o foo foo.c .Ve .SS "\s-1LESSON:\s0 Stripped-Down Markup Code" .IX Subsection "LESSON: Stripped-Down Markup Code" Now let's try an example which has unnecessary whitespaces. Be careful, `unnecessary' here means they can be stripped as long as the resulting Webpage displays the same in a Webbrowser as the original. .PP Input: .PP .Vb 9 \& 1| \& 2| \& 3|   test  \& 4|
\& 5|
\& 6|     Preformatted          Text
\& 7| 
\& 8| Not Preformatted Text \& 9| .Ve .PP Output: .PP .Vb 8 \& 1| \& 2|  test \& 4|
\& 5|
\& 6|     Preformatted          Text
\& 7| 
\& 8| Not Preformatted Text \& 9| .Ve .PP Here we see that line 2 is completely removed because empty lines have no effect in \s-1HTML.\s0 The whitespaces between the attribute \f(CW\*(C`src\*(C'\fR and its value are removed, too. And all double whitespaces are replaced by a single whitespace character. But not inside preformatted areas. .SS "\s-1LESSON:\s0 Fixed And Adjusted Markup Code" .IX Subsection "LESSON: Fixed And Adjusted Markup Code" Now assume that we have an \fIimage.gif\fR file containing a \s-1GIF\s0 image with a size of 500x400 pixels and the following input page: .PP .Vb 6 \& 1| \& 2|
\& 3| Headline:
\& 4| \& 5|
\& 6| .Ve .PP Although this is valid \s-1HTML\s0 code, \s-1WML\s0 can enhance it to make it more portable, speed up it rendering in the Webbrowser and make \fILynx\fR users more happy. So \&\s-1WML\s0 recognizes the \f(CW\*(C`\*(C'\fR tag and automatically adds missing information and replaces obsolete tags with up-to-date variants: .PP .Vb 6 \& 1| \& 2|
\& 3| Headline:
\& 4| \& 5|
\& 6| .Ve .PP As you can see, \s-1WML\s0 first replaced the proprietary \f(CW\*(C`
\*(C'\fR tag with the \s-1HTML 3.2\s0 pedant \f(CW\*(C`
\*(C'\fR, second it fixed the \&\f(CW\*(C`color\*(C'\fR attribute of \f(CW\*(C`\*(C'\fR. And third it added missing \f(CW\*(C`alt\*(C'\fR and \&\f(CW\*(C`width\*(C'\fR/\f(CW\*(C`height\*(C'\fR attributes. .SH "STRUCTURING THE MARKUP CODE" .IX Header "STRUCTURING THE MARKUP CODE" .SS "\s-1LESSON:\s0 Using Include Files" .IX Subsection "LESSON: Using Include Files" One of the most useful features of \s-1WML\s0 is the ability to move commonly used stuff into include files which can be selectively read in at later steps. .PP Assume we have an include file \fIbar.wml\fR... .PP .Vb 2 \& 1| bar \& 2| The value of bar is: $(bar:\-unknown) .Ve .PP \&...and the following input file: .PP .Vb 4 \& 1| foo \& 3| #include \*(Aqbar.wml\*(Aq bar="FooBar" \& 2| #include \*(Aqbar.wml\*(Aq \& 5| quux .Ve .PP Then the output is: .PP .Vb 6 \& 1| foo \& 2| bar \& 3| The value of bar is: Foobar \& 4| bar \& 5| The value of bar is: unknown \& 6| quux .Ve .PP As you can see, the \f(CW\*(C`#include\*(C'\fR directive is replaced by the contents of the corresponding file. And this included contents can contain variables which are interpolated when they are defined, inclusive default values. .PP There is also a way to create simple constructs similar to an if-then-else just by using variable interpolation: .PP .Vb 1 \& 1| The value of bar is $(bar:+set)$(bar:*unset). .Ve .PP Here the `\f(CW\*(C`$(bar:+set)$(bar:*unset)\*(C'\fR' construct emulates the following semantics: .PP .Vb 4 \& if (isdefined(bar)) \& expandto("set") \& if (not isdefined(bar)) \& expandto("unset") .Ve .SS "\s-1LESSON:\s0 Concatenating Lines" .IX Subsection "LESSON: Concatenating Lines" Although \s-1HTML\s0 usually does not care about whitespaces and newlines, sometimes it is very frustrating to create preformatted areas or write own tags (see later) without the ability to spread the code over more than one line while it should be actually one single line. For this a lot of languages use a line concatenation/continuation character `\f(CW\*(C`\e\*(C'\fR', as does \s-1WML.\s0 .PP Input: .PP .Vb 3 \& 1| foo\e \& 2| bar \e \& 3| quux .Ve .PP Output: .PP .Vb 1 \& 1| foobar quux .Ve .PP The line concatenation strips whitespaces from the begin of concatenated lines but preserves whitespaces at the end of them, i.e. you can use leading whitespaces for structuring your input nicely but still use appended whitespaces for real ones. .SS "\s-1LESSON:\s0 Diverting To Locations" .IX Subsection "LESSON: Diverting To Locations" One of the most powerful features of \s-1WML\s0 is the ability to \&\fIdivert\fR data at any point to \fIlocations\fR defined at any other point. .PP Input: .PP .Vb 7 \& 1| {#BAR#:this is:##} \& 2| foo \& 3| {#BAR#} \& 4| quux \& 5| {#BAR#: bar:##} \& 6| foobar \& 7| {#BAR#} .Ve .PP Output: .PP .Vb 5 \& 1| foo \& 2| this is bar \& 3| quux \& 4| foobar \& 5| this is bar .Ve .PP Here in line 3 the location \f(CW\*(C`BAR\*(C'\fR is already dumped, but filled at lines 1 and 5. And as you can see a location can be dumped at any point and even more than once. And you can accumulate the contents for a location by subsequent fills (line 1 and 5). This works because in \s-1WML\s0 first all locations are filled in a first pass and then dumped in a second pass. .PP With the use of the high-level tags from \fIwml::std::tags\fR we also could write the example above in a little bit more human readable way: .PP .Vb 8 \& 1| #use wml::std::tags \& 2| this is \& 3| foo \& 4| \& 5| quux \& 6| bar \& 7| foobar \& 8| .Ve .SS "\s-1LESSON:\s0 Defining Output Slices" .IX Subsection "LESSON: Defining Output Slices" Often one needs more than one output file. Usually although 90% of the contents is the same, one needs a way to select the remaining 10%. \s-1WML\s0's approach here is to write these 10% directly in the input file but separate the variants by defining \fIslices\fR which later can be used to create the different output files. .PP .Vb 8 \& 1| \& 2| \& 3| [EN:Titleline:][DE:Titelzeile:] \& 4| \& 5| \& 6|

[EN:Headerline:][DE:Ueberschrift:]

\& 7| \& 8| .Ve .PP Now assume the above page is in file \fIindex.wml\fR, then the command .PP .Vb 2 \& $ wml \-o UNDEF+EN:index.html.en \e \& \-o UNDEF+DE:index.html.de index.wml .Ve .PP generates the output file \f(CW\*(C`index.html.en\*(C'\fR containing the union of all undefined areas and the slices `\f(CW\*(C`EN\*(C'\fR'... .PP .Vb 8 \& 1| \& 2| \& 3| Titleline \& 4| \& 5| \& 6|

Headerline

\& 7| \& 8| .Ve .PP \&...and the output file \f(CW\*(C`index.html.de\*(C'\fR containing the union of all undefined areas and the slices `\f(CW\*(C`DE\*(C'\fR': .PP .Vb 8 \& 1| \& 2| \& 3| Titelzeile \& 4| \& 5| \& 6|

Ueberschrift

\& 7| \& 8| .Ve .SH "FORMATTING" .IX Header "FORMATTING" .SS "\s-1LESSON:\s0 Area Substitution" .IX Subsection "LESSON: Area Substitution" \&\s-1WML\s0 provides an area substitution feature which works by specifying the begin and end of the area and inserting some Perl substitution and translation commands. .PP Input: .PP .Vb 5 \& 1| foo \& 2| {: [[s/foo/bar/g]] [[s/quux/foobar/g]] [[tr/[a\-z]/[A\-Z]/]] \& 3| this is foo and quux. \& 4| :} \& 5| quux .Ve .PP Output: .PP .Vb 3 \& 1| foo \& 2| THIS IS BAR AND FOOBAR. \& 3| quux .Ve .PP Because this seems useless, we go further and show an example of the \&\f(CW\*(C`\*(C'\fR and \f(CW\*(C`\*(C'\fR container tags from \&\fIwml::fmt::isolatin\fR and \fIwml::fmt::url\fR which are programmed this way. .PP Input: .PP .Vb 6 \& 1| #use wml::fmt::isolatin \& 2| #use wml::fmt::url \& 3| \& 4| Some umlauts \`XXXXXX\*(Aq and \& 5| a hyperlink http://foo.bar.com/ \& 6| .Ve .PP Output: .PP .Vb 2 \& 1| Some umlauts \`öäüÖÄß\*(Aq and \& 2| a hyperlink http://foo.bar.com/ .Ve .SS "\s-1LESSON:\s0 Text Formatting" .IX Subsection "LESSON: Text Formatting" \&\s-1HTML\s0 sucks when it comes to write more than one paragraph of text. So \s-1WML\s0 provides nice ways to format an area of input via other (externally available) markup language processors. Here is an example which used two embedded areas, the first one is written in \fIPlain Old Document\fR (\s-1POD\s0) format, second one is written in \fISimple Document Format\fR (\s-1SDF\s0). .PP Input: .PP .Vb 10 \& 1| #use wml::fmt::pod \& 2| #use wml::fmt::sdf \& 3| \& 4| \& 5| =head1 Headline1 \& 6| \& 7| Foo \& 8| \& 9| =head2 Headline1.1 \& 10| \& 11| Bar \& 12| \& 13| \& 14| \& 15| H1: Headline1 \& 16| \& 17| Foo \& 18| \& 19| H2: Headline 1.1 \& 20| \& 21| Bar \& 22| * Baz \& 23| \- Foobar \& 24| \- Quux \& 25| * Foo \& 26| \& 27| .Ve .PP Output: .PP .Vb 10 \& 1| \& 2|

\& 3|

Headline1 \& 4|

\& 5| Foo \& 6|

\& 7|

Headline1.1 \& 8|

\& 9| Bar \& 10|

\& 11|

1. Headline1

\& 12|

Foo

\& 13|

1.1. Headline 1.1

\& 14|

Bar

\& 15|
    \& 16|
  • Baz
      \& 17|
    • Foobar \& 18|
    • Quux
    \& 19|
  • Foo
\& 20| .Ve .SS "\s-1LESSON:\s0 Table Formatting" .IX Subsection "LESSON: Table Formatting" Another point where the \s-1HTML\s0 markup code is unproductive and ugly is when it comes to write some \f(CW\*(C`\*(C'\fR structures. Here \s-1WML\s0 provides two new container tags which make your live easier: .IP "\fB\fR" 4 .IX Item "" The goal of this container tag is to provide a way to specify tables the same way you have it in your mind, i.e. as a 2\-dimensional grid. So, a grid is created by specifying a grid-layout and then fill its cells. Additionally the \&\f(CW\*(C`\*(C'\fR container tag provides a nice feature for specifying the cell alignments. .Sp Input: .Sp .Vb 6 \& 1| #use wml::std::grid \& 2| \& 3| Header 1 Header 2 \& 4| Cell\-A Cell\-B \& 5| Cell\-C Cell\-D \& 6| .Ve .Sp Output: .Sp .Vb 10 \& 1|
\& 2| \& 3| \& 4| \& 5| \& 6| \& 7| \& 8| \& 9| \& 10| \& 11| \& 12| \& 13| \& 14|
Header 1Header 2
Cell\-ACell\-B
Cell\-CCell\-D
.Ve .IP "\fB\fR" 4 .IX Item "" This is the extended \f(CW\*(C`\*(C'\fR container tag which syntax is provided by the external \fIfreetable\fR program. Its goal is to provide a compact syntax for specifying a table. Again the same example: .Sp Input: .Sp .Vb 10 \& 1| #use wml::fmt::xtable \& 2| \& 3| (*, 1) align=left \& 4| (*, 2) align=right \& 5| (1, *) valign=top \& 6| (2|3, *) valign=bottom \& 7| (1,1) \& 8| Header 1 \& 9| (1,2) \& 10| Header 2 \& 11| (2,1) \& 12| Cell\-A \& 13| (2,2) \& 14| Cell\-B \& 15| (3,1) \& 16| Cell\-C \& 17| (3,2) \& 18| Cell\-D \& 19| .Ve .Sp Output: .Sp .Vb 10 \& 1|
\& 2| \& 3| \& 4| \& 5| \& 6| \& 7| \& 8| \& 9| \& 10| \& 11| \& 12| \& 13| \& 14|
Header 1Header 2
Cell\-ACell\-B
Cell\-CCell\-D
.Ve .SH "DEFINITION OF OWN HTML TAGS" .IX Header "DEFINITION OF OWN HTML TAGS" .SS "\s-1LESSON:\s0 Simple Tags And Container Tags" .IX Subsection "LESSON: Simple Tags And Container Tags" Now it is time to enhance our markup language by defining new custom \s-1HTML\s0 tags. There are two types of \s-1HTML\s0 tags: .IP "\fBSimple Tags\fR" 4 .IX Item "Simple Tags" As an example let us define a \f(CW\*(C`\*(C'\fR tag which expands to my name abbreviation. .Sp Input: .Sp .Vb 5 \& 1| \& 2| rse@engelschall.com \& 3| \& 4| \& 5| This is . .Ve .Sp Output: .Sp .Vb 1 \& 1| This is rse@engelschall.com. .Ve .IP "\fBContainer Tags\fR" 4 .IX Item "Container Tags" As an example let us define a \f(CW\*(C`\*(C'\fR tag which changes its body text color to red. .Sp Input: .Sp .Vb 5 \& 1| \& 2| %body \& 3| \& 4| \& 5| This is very important. .Ve .Sp Output: .Sp .Vb 1 \& 1| This is very important. .Ve .SS "\s-1LESSON:\s0 Tags With Attributes" .IX Subsection "LESSON: Tags With Attributes" Because tags without attributes are not very flexible there is also a way to define tags which can use these. .PP Input: .PP .Vb 10 \& 1| \& 2| \& 3| \& 4| \& 5| \& 6| \& 7| \& 8| \& 9| \& 10| This is and . .Ve .PP Output: .PP .Vb 1 \& 1| This is rse@engelschall.com and rse@apache.org. .Ve .PP There is also a variant to use attributes of type \f(CW\*(C`name=value\*(C'\fR: .PP Input: .PP .Vb 10 \& 2| \& 3| \& 4| \& 5| " "" "rse@engelschall.com"> \& 6| " "engelschall" "rse@engelschall.com"> \& 7| " "netsw" "rse@netsw.org"> \& 8| " "apache" "rse@apache.org"> \& 9| " "freebsd" "rse@freebsd.org"> \& 10| " "sdm" "rse@sdm.de"> \& 11| \& 12| \& 13| \& 14| This is and . .Ve .PP Output: .PP .Vb 1 \& 1| This is rse@engelschall.com and rse@apache.org. .Ve .SS "\s-1LESSON:\s0 Overwriting Existing \s-1HTML\s0 Tags" .IX Subsection "LESSON: Overwriting Existing HTML Tags" \&\s-1WML\s0 also provides a way to overwrite existing \s-1HTML\s0 tags, i.e. you can define a custom tag with the same name as an already known \s-1HTML\s0 tag and use the original \s-1HTML\s0 tag inside it. .PP Input: .PP .Vb 6 \& 1| \& 2| \& 4| \& 5| \& 6| Some Text
\& 7| Some more Text .Ve .PP Output: .PP .Vb 2 \& 1| Some Text

\& 2| Some more Text .Ve .SS "\s-1LESSON:\s0 Programming Tags In Perl" .IX Subsection "LESSON: Programming Tags In Perl" One of the essential features in \s-1WML\s0 is that you can embed Perl code at any point, just marked with `\f(CW\*(C`<:\*(C'\fR' and `\f(CW\*(C`:>\*(C'\fR' delimiters. This can be combined with the tag definitions by programming tags in Perl. .PP Input: .PP .Vb 10 \& 1| #use wml::std::tags \& 2| \& 3| \& 4| \& 5| <:{ \& 6| my $at = qq//; \& 7| my $addr; \& 8| $addr = "rse\e@engelschall.com" if $at eq \*(Aq\*(Aq; \& 9| $addr = "rse\e@engelschall.com" if $at eq \*(Aqengelschall\*(Aq; \& 10| $addr = "rse\e@netsw.org" if $at eq \*(Aqnetsw\*(Aq; \& 11| $addr = "rse\e@apache.org" if $at eq \*(Aqapache\*(Aq; \& 12| $addr = "rse\e@freebsd.org" if $at eq \*(Aqfreebsd\*(Aq; \& 13| $addr = "rse\e@sdm.de" if $at eq \*(Aqsdm\*(Aq; \& 14| print $addr; \& 15| }:> \& 16| \& 17| \& 18| \& 19| This is and . .Ve .PP Output: .PP .Vb 1 \& 1| This is rse@engelschall.com and rse@apache.org. .Ve .SH "ADVANCED FEATURES" .IX Header "ADVANCED FEATURES" .SS "\s-1LESSON:\s0 Using Templates" .IX Subsection "LESSON: Using Templates" We've already seen how to divert data to a location. Because \s-1WML\s0 automatically closes still opened diversions at EndOfFile, we can use this feature to create templates. Assume we have the following template defined in the file \fItemplate.wml\fR. .PP .Vb 10 \& 1| # the template itself \& 2| \& 3| \& 4| {#SUBJECT_LOC#} \& 5| \& 6| \& 7|

{#SUBJECT_LOC#}

\& 8|
\& 9| {#BODY#} \& 10|
\& 11| \& 12| \& 13| \& 14| # way to insert the subject \& 15| \& 16| {#SUBJECT_LOC#:%0:##} \& 17| \& 18| \& 19| # per default we are in body \& 20| {#BODY#: .Ve .PP Input: .PP .Vb 5 \& 1| #include \*(Aqtemplate.wml\*(Aq \& 2| \& 3| \& 4| \& 5| This is about Foo, Bar and Quux... .Ve .PP Output: .PP .Vb 11 \& 1| \& 2| \& 3| Foo, Bar and Quux \& 4| \& 5| \& 6|

Foo, Bar and Quux

\& 7|
\& 8| This is about Foo, Bar and Quux... \& 9|
\& 10| \& 11| .Ve .PP You can even nest more than one template because the diversion mechanism in \&\s-1WML\s0 accepts location dumps and location fills at any point, even within other location fills. .SS "\s-1LESSON:\s0 Creating Multi-Lingual Pages" .IX Subsection "LESSON: Creating Multi-Lingual Pages" The core languages of \s-1WML\s0 don't provide a dedicated facility to create multi-lingual pages, i.e. one or more output pages created out of a single input source, each one containing the same page information but in different human languages. But \s-1WML\s0 provides variants through ``slicing'' (Pass 9) and human languages are just a special case of general variants. So wml::std::lang exists which provides specialized multi-lingual support tags which are mapped to slices which then can be used to create the various output files. .PP Let take an example: .PP .Vb 10 \& 1| #!wml \-o (ALL\-LANG_*)+LANG_EN:index.en.html \e \& 2| \-o (ALL\-LANG_*)+LANG_DE:index.de.html \& 3| \& 4| #use wml::std::page \& 5| #use wml::std::lang \& 6| \& 7| \& 8| \& 9| \& 10| \& 11| \& 12|

!

\& 13| \& 14| Index 2 \& 15| \& 16| \& 17| (en)This is a test page \& 18| (de)Dies ist eine Testseite \& 19| .Ve .PP After processing passes 1 to 8 (\f(CW\*(C`wml \-p1\-8\*(C'\fR) the following is internally generated by \s-1WML:\s0 .PP .Vb 10 \& 1| \& 2| \& 3| \& 4| \& 5|

[LANG_EN:Welcome:][LANG_DE:Willkommen:]!

\& 6| Index 2 \& 7| [LANG_EN:This is a test page \& 8| :][LANG_DE:Dies ist eine Testseite:] \& 9| \& 10| .Ve .PP And then after processing pass 9 with the initial \s-1WML\s0 magic cookie line (\f(CW\*(C`#!wml \-o...\*(C'\fR) the following two files are generated: .PP index.en.html: .PP .Vb 10 \& 1| \& 2| \& 3| \& 4| \& 5|

Welcome!

\& 6| Index 2 \& 7| This is a test page \& 8| \& 9| \& 10| .Ve .PP index.de.html: .PP .Vb 9 \& 1| \& 2| \& 3| \& 4| \& 5|

Willkommen!

\& 6| Index 2 \& 7| Dies ist eine Testseite \& 8| \& 9| .Ve .PP And these two pages then can be served by a content negotiation feature of the webserver or by explicit references. .SH "MORE INFORMATION" .IX Header "MORE INFORMATION" Now you've seen the various core languages of \s-1WML\s0 in action. For the gory details of what each language provides either read the all-in-one \s-1WML\s0 Introduction in \fBwml_intro\fR\|(7) or step through the particular manpages of the core languages. Start here with the frontend \fBwml\fR\|(1). .PP Additionally can can step through the set of available standard include files \&\s-1WML\s0 ships with. Start with the top-level include file \fBwml::all\fR\|(3). .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fBwml_intro\fR\|(7) .PP \&\fBwml_p1_ipp\fR\|(3), \&\fBmp4h\fR\|(1), \&\fBeperl\fR\|(1), \&\fBm4\fR\|(1), \&\fBwml_p5_divert\fR\|(3), \&\fBwml_p6_asubst\fR\|(3), \&\fBwml_p7_htmlfix\fR\|(3), \&\fBwml_p8_htmlstrip\fR\|(3), \&\fBslice\fR\|(1). .PP \&\fBwml::all\fR\|(3)