GuiSGML documentation is stored in templated SGML files which can be used to understand GuiSGML.
Both the source and published form of the documentation is in the archive.
Basic Example,
TEMPLATE APPEND argument,
Advanced Example (Args),
Directory Parsing
Basic Example |
Using this technique on a whole site can allow you to change the colours of ALL the web pages by changing the BODY in the template, and re-publishing the whole site. Only 1 file edit, wow. GuiSGML checks the date of the destination file if it already exists and ONLY overwrites it if the source (or templates used by it) changed since the destination file was written.
This makes it easy to write scripts to upoad files to a server based on todays date - much more efficient.
The interesting thing to note in this example is the /BODY in the source file, but no BODY because that is in the template. This ensures that the BODY has a matching /BODY once the file is parsed (see the published file). However, there is a better solution than having these /BODY tags hanging around. More on that later.
| Template File | Source File |
|---|---|
<NEWTEMPLATE NAME=BODYTEMPLATE> <BODY BGCOLOR=blue> </NEWTEMPLATE> | <HTML> <TEMPLATE NAME=BODYTEMPLATE> Hello World </TEMPLATE> </BODY> </HTML> |
Published File
<HTML> <BODY BGCOLOR=blue> Hello World </BODY> </HTML> | |
As you will see in the next example the /BODY has been dropped, but a new argument has been added (APPEND=/BODY) to the TEMPLATE directive in the source file to automatically add the /BODY.
This will be added at the end of the template, where the /TEMPLATE is.
APPEND Argument |
| Template File | Source File |
|---|---|
Using the same template as above<NEWTEMPLATE NAME=BODYTEMPLATE> <BODY BGCOLOR=blue> </NEWTEMPLATE> | <HTML> <TEMPLATE NAME=BODYTEMPLATE APPEND=/BODY> Hello World </TEMPLATE> </HTML> |
Published File<HTML> <BODY BGCOLOR=blue> Hello World </BODY> </HTML> |
Advanced Example - Arguments |
To pass an argument, add to the NEWTEMPLATE directive an argument name, URLTEXT in this case. Then in the template itself, reference the argname with a $ or $(), eg $URLTEXT or $(URLTEXT), When you reference a template simply add the argument name to the TEMPLATE directive as shown below. If the argument isn't supplied, an environment variable is looked for. If there isn't an environment variablethe template will parse out the variable reference so it doesn't show.
| Template File | Source File |
|---|---|
<NEWTEMPLATE NAME=LISTDIR FILENAME> <LI>$FILENAME </NEWTEMPLATE> | <HTML><BODY><UL> <TEMPLATE NAME=LISTDIR READDIR=ram:> </TEMPLATE></UL></BODY></HTML> |
Published File<HTML><BODY><UL> <LI>ram:T<LI>ram:Clipboards<LI>ram:env <LI>ram:T/Command-01-T01<LI>ram:Clipboards<LI>ram:env </UL></BODY></HTML> | |
Questions? Drop the author an email.