-
Notifications
You must be signed in to change notification settings - Fork 7
/
stdwebtemplate.pp
57 lines (43 loc) · 1.28 KB
/
stdwebtemplate.pp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
unit StdWebTemplate;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, QTemplate;
type
{ TStdWebTemplate }
TStdWebTemplate = class(TQTemplate)
private
function ReplaceCSS(const ATag: String; AParams: TStringList): String;
function ReplaceJS(const ATag: String; AParams: TStringList): String;
function ReplaceURL(const ATag: String; AParams: TStringList): String;
public
constructor Create(const AFileName: String); override;
end;
implementation
{ TStdWebTemplate }
function TStdWebTemplate.ReplaceCSS(const ATag: String; AParams: TStringList
): String;
begin
Result := '<link rel="stylesheet" type="text/css" href="' +
AParams.Values['FileName'] + '" />';
end;
function TStdWebTemplate.ReplaceJS(const ATag: String; AParams: TStringList
): String;
begin
Result := '<script type="text/javascript" src="' +
AParams.Values['FileName'] + '"></script>';
end;
function TStdWebTemplate.ReplaceURL(const ATag: String; AParams: TStringList
): String;
begin
Result := '<a href="' + AParams.Values['href'] + '">' +
AParams.Values['text'] + '</a>';
end;
constructor TStdWebTemplate.Create(const AFileName: String);
begin
inherited Create(AFileName);
Tags['css'] := @ReplaceCSS;
Tags['js'] := @ReplaceJS;
Tags['url'] := @ReplaceURL;
end;
end.