Re: [fpc-pascal] The best approaching for templating

2011-11-09 Thread ABorka

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"
À: fpc-pascal@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:



%s


%s
%s
%s



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  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] The best approaching for templating

2011-11-09 Thread Jorge Aldo G. de F. Junior
I once wrote a very nice template system for Powutils.

Dont remember how it was called.

I can search the svn for you if you want.

2011/11/9 tcoq :
> 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" 
> À: fpc-pascal@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:
>
> 
> 
> %s
> 
> 
> %s 
> %s 
> %s 
> 
> 
>
> 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@lists.freepascal.org
> http://lists.freepascal.org/mailman/listinfo/fpc-pascal
> ___
> fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
> http://lists.freepascal.org/mailman/listinfo/fpc-pascal
>
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] The best approaching for templating

2011-11-09 Thread tcoq
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" 
À: fpc-pascal@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:



%s


%s 
%s 
%s 



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@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal