[fpc-pascal] The best approaching for templating
ABorka
fpc-devel at aborka.com
Thu Nov 10 00:10:27 CET 2011
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"<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
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
More information about the fpc-pascal
mailing list