[fpc-pascal] Generating templates with FPTemplate
luciano de souza
luchyanus at gmail.com
Fri Jul 27 13:03:02 CEST 2012
Hello all,
I am trying to create an example with the FPTemplate unit. Firstly, I
wrote a hypothetical unit template.
{e030.txt}
unit <#name>;
{$mode objfpc}{$H+}
interface
uses
<#modules>
implementation
end.
And now the code:
{e030.pp}
program e030;
{$mode objfpc}{$H+}
uses
fptemplate, classes;
var
source: TFPTemplate;
parser: TTemplateParser;
BEGIN
source := TFPTemplate.create;
parser := TTemplateParser.create;
try
source.filename := 'e030.txt';
parser.values['name'] := 'freevox';
parser.values['modules'] := 'sysutils, classes';
writeln(parser.ParseString(source.template));
finally
parser.free;
source.free;
end;
end.
I am not successful in filling up the template. If I do
writeln(source.template), the answer is an empty string. If I do
writeln(source.GetContent), the answer is the template without the
needed replacements.
So I ask: what is wrong? How can I get a file, to replace tags and to
get a replaced string?
Regards,
--
Luciano de Souza
More information about the fpc-pascal
mailing list