On 11/9/2011 14:27, tcoq wrote:
Dear Luciano.
I would suggest using the StringReplace function (Sysutiles) in combination
with a TStringList.
Easy to do and quite powerful.
You can also use a second string list to store the values and patterns to
replace, using the Names and Values properties, so that you can do multiple
successive replacements in your templates.
The SaveToFile and LoadFromFile will give you easy storage of your templates.
I tend to use patterns like [Name] or (First_Name] that are not confused with
the html.
Best regards,
Thierry
----- Mail Original -----
De: "luciano de souza"<[email protected]>
À: [email protected]
Envoyé: Lundi 7 Novembre 2011 14h37:46 GMT +01:00 Amsterdam / Berlin / Berne /
Rome / Stockholm / Vienne
Objet: [fpc-pascal] The best approaching for templating
Hello listers,
I would like to create some templates. Suppose the following example:
<html>
<head>
<title>%s</title>
</head>
<body>
%s<p>
%s<p>
%s<p>
</body>
</html>
I can certainly use format to link %s to the respective variables.
However, if the number of %s is big, probabily, the reading would be
less clearer.
But, suppose I have $title in stead of %s and $p1 in stead of %s. In
Lua, I have a module called Cosmo taht perform it.
my question is: is there something similar in Pascal?
Luciano
There is a full template handling unit called fpTemplate included in FPC
( readme is found under FPC /packages/fcl-base/texts/fptemplate.txt ).
There are also multiple web examples using templates found under FPC
/packages/fcl-web/examples/fptemplate/
AB
_______________________________________________
fpc-pascal maillist - [email protected]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal