GetTemplate |
Strings | |
| Aptilis 2.4 | ||
GetTemplate (Template_Name)
Returns a template defined with the template directive somewhere in your Aptilis script.
Return Value:
The template in a string or an empty string in case of error (_errno$ may tell you why).
Example 1:
#!/usr/bin/aptilis.exe
template PageTop
<html>
<head>
<title>My Homepage</title>
</head>
<body>
end PageTop
template PageBottom
<hr size="1" width="80%">
© 2004 by Donald McRonald
</body>
</html>
end PageBottom
sub main
pageTop = getTemplate("PageTop") $
pageBottom = getTemplate("PageBottom") $
print("Context-type: text/html\n\n")
print(pageTop$, someContent$, pageBottom$)
end main
Example 2:
#!/usr/bin/aptilis.exe
template Database
"Mr.","Bond","James","MI6"
"Mr.","Hunt","Ethan","IMF"
"Mr.","Mulder,"Fox","FBI"
end template
sub main
n = parseDatabase(db[], getTemplate("Database")$)
print("Good Morning, ", getField(db[1]$,0)$, " ", getField(db[1]$,1)$)
end main
Result:
Good Morning, Mr. Hunt |
Example 3:
#!/usr/bin/aptilis.exe
template TestTemplate
this won't terminate the template:
end TestTemplate
this won't, too:
end TestTemplate Test
but this terminates it:
end template
this would terminate it, too - if it wasn't already terminated by the previous "end template":
end TestTemplate
sub main
print(getTemplate("TestTemplate")$)
end main
Result:
this won't terminate the template: end TestTemplate this won't, too: end TestTemplate Test but this terminates it: |
See also Template
