On 27/7/2012 08:51, leledumbo wrote:
try this:type TMyTemplate = class(TFPTemplate) private procedure ReplaceMyTags(Sender : TObject; Const TagString : String; TagParams:TStringList; Out ReplaceText : String); public constructor Create; end; procedure TMyTemplate.ReplaceMyTags(Sender : TObject; Const TagString : String; TagParams:TStringList; Out ReplaceText : String); begin // use if-else if-else if your compiler version doesn't support case statement with string variable case TagString of 'name': ReplaceText := 'sysutils, classes'; 'modules': ReplaceText := 'freevox'; end; end; constructor TMyTemplate.Create; begin inherited Create; StartDelimiter := '<#'; EndDelimiter := '>'; OnReplaceTag := @ReplaceMyTags; end; begin with TMyTemplate.Create do try FileName := 'e030.txt'; WriteLn(GetContent); finally Free; end; end. if you want to use your style, you can try adapting http://free-pascal-general.1045716.n5.nabble.com/file/n5710450/view.pp my unit . It's more or less like what you want, only with more features as I support parameters. -- View this message in context: http://free-pascal-general.1045716.n5.nabble.com/Generating-Yes, it's really very good. An example like that could be added to the source package. Templating with parameters? Oh! Yes, there are lots of interesting things I can do with it! Thank you!
templates-with-FPTemplate-tp5710448p5710450.html Sent from the Free Pascal - General mailing list archive at Nabble.com. _______________________________________________ fpc-pascal maillist - [email protected] http://lists.freepascal.org/mailman/listinfo/fpc-pascal
_______________________________________________ fpc-pascal maillist - [email protected] http://lists.freepascal.org/mailman/listinfo/fpc-pascal
