[fpc-pascal] The best approaching for templating
tcoq
tcoq at free.fr
Wed Nov 9 23:27:32 CET 2011
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" <luchyanus at gmail.com>
À: fpc-pascal at lists.freepascal.org
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
_______________________________________________
fpc-pascal maillist - fpc-pascal at lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
More information about the fpc-pascal
mailing list