






|
Example 2:
Config File: File: config.txt |
BodyColor = green |
HelloFontB = <font color="green"><I> |
HelloFontE = </I></font> |
|
Template: File: templ.txt |
<HTML> |
<BODY bgcolor="@BodyColor@> |
@HelloFontB@ Hello mister @Name@ @HelloFontE@ |
</BODY> |
</HTML> |
|
Program: |
templateLoader.setPath("c:\\", "config.txt"); |
template = templateLoader.getTemplate("templ") |
out.addSubstitute("Name", "George Ter-Saakov") |
template.outputToBrowser( out ) |
|
Browser: |
<HTML> |
<BODY bgcolor="green"> |
<font color="green"><I> Hello mister George
Ter-Saakov </I></font> |
</BODY> |
</HTML> |
|
Here BodyColor, HelloFontB and HelloFontE are global tags for global
substitutor. They will be substituted only first time when template compiled. @Name@ is
local substitutor it will be substituted to real name at runtime. We do not show here
where we get that real name. It's up to you.


|
|