Skip to content

Commit

Permalink
Merge pull request #193 from sempare/dev
Browse files Browse the repository at this point in the history
Update 1.7.7
  • Loading branch information
darnocian authored Aug 10, 2024
2 parents 59dc87c + d6a782b commit 1616df4
Show file tree
Hide file tree
Showing 7 changed files with 272 additions and 33 deletions.
15 changes: 15 additions & 0 deletions demo/WebReporting/WebReporting.dpr
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ type
HighScores: TArray<TPerson>;
end;

TWebReportingFunctions = class
public
class function JoinNames(const APerson: TPerson): string; static;

end;

{ TPerson }

constructor TPerson.Create(const AFN, ALN: string; const AScore: integer);
Expand All @@ -29,8 +35,17 @@ begin
Score := AScore;
end;

{ TWebReportingFunctions }

class function TWebReportingFunctions.JoinNames(const APerson: TPerson): string;
begin
exit(format('%s %s', [APerson.FirstName, APerson.LastName]));
end;

begin
try
Template.Resolver.Context.Functions.AddFunctions(TWebReportingFunctions);

THorse.Get('/',
procedure(Req: THorseRequest; Res: THorseResponse)
var
Expand Down
7 changes: 7 additions & 0 deletions demo/WebReporting/WebReporting.dproj
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@
<MainSource>MainSource</MainSource>
</DelphiCompile>
<None Include="templates\index.tpl"/>
<None Include="templates\layout.tpl"/>
<BuildConfiguration Include="Base">
<Key>Base</Key>
</BuildConfiguration>
Expand Down Expand Up @@ -265,6 +266,12 @@
<Overwrite>true</Overwrite>
</Platform>
</DeployFile>
<DeployFile LocalName="templates\layout.tpl" Configuration="Debug" Class="ProjectFile">
<Platform Name="Win32">
<RemoteDir>.\</RemoteDir>
<Overwrite>true</Overwrite>
</Platform>
</DeployFile>
<DeployClass Name="AdditionalDebugSymbols">
<Platform Name="iOSSimulator">
<Operation>1</Operation>
Expand Down
41 changes: 21 additions & 20 deletions demo/WebReporting/templates/index.tpl
Original file line number Diff line number Diff line change
@@ -1,23 +1,24 @@
<% extends 'layout' %>
<% block 'header' %>
<title>The high scores for the Dev Days 2024 demo</title>
<% end %>
<% block 'body' %>
<h1>High Scores</h1>

<% for person of HighScores %>
<tr>
<td><% JoinNames(person) %></td>
<td><% person.score %></td>
</tr>
<% onbegin %>
<table>
<% onend %>
</table>
<% onempty %>

There are no high scores available.
<% end %>
<% end %>

<h1>High Scores</h1>




<% for person of HighScores %>
<tr>
<td><% person.firstname %></td>
<td><% person.lastname %></td>
<td><% person.score %></td>
</tr>
<% onbegin %>
<table>
<% onend %>
</table>
<% onempty %>

There are no high scores available.
<% end %>



12 changes: 12 additions & 0 deletions demo/WebReporting/templates/layout.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<html>
<header>
<% block 'header' %>
<title>This is the web reporting demo</title>
<% end %>
</header>
<body>
<% block 'body' %>
This is a placeholder for content
<% end %>
</body>
</html>
16 changes: 16 additions & 0 deletions docs/statements.md
Original file line number Diff line number Diff line change
Expand Up @@ -590,6 +590,22 @@ begin

include() can also take a second parameter, allowing for improved scoping of variables, similar to the _with_ statement.

We have a 'functional' include syntax:
```
<% template 'button' %>
<button text="<% text %>">
<% end %>
<% button { text="add" } %>
or
<% button text="remove" %>
```

Above we can see we don't need to use the explict 'include' statement.


<a name="require"><h3>require</h3></a>

![require](./images/stmt_require.svg)
Expand Down
Loading

0 comments on commit 1616df4

Please sign in to comment.