Hi,
Just a small announcement that a new version (v1.4.0) has been released.
Changes:
NEW: Context.StreamWriterProvider which allows greater flexibility in providing custom overrides to the StreamWriter
NEW: Support for statement start and end tokens allowing for content to be swallowed (useful when statements are multi line)
NEW: Added helper variables and functions for spaces, newlines, tabs, chr() and ord()
FIX: Issue with custom text writer that supported a few options regarding newlines, but had a bug when it came to carriage returns. (not noticeable under html)
FIX: Fixed a double free bug in a ParseFile helper.
UPDATE: Documentation updates
Context.StreamWriterProvider flexibility
var ctx := Template.Context();
ctx.StreamWriterProvider := function(const AStream: TStream; AContext: ITemplateContext): TStreamWriter
begin
result := TStreamWriter.Create(AStream);
end;
The above is an example of how the override can be done on a per context basis. There is a GDefaultStreamProvider which is used when the context is initially created which can be used for global initialisation.
Allow swallowing of content between start and end statement tokens
Say you have a scenario like:
<% for i := 1 to 5 %>
<% i %>
<% end %>
What you may notice is that there are many newlines that appear something like:
1
2
3
4
5
Now consider the following:
<% for i := 1 to 5 |>
<% i %>
<| end %>
In this scenario, all normal output between |> and <| are ignored, except statements such as explicit print() or variable references will work as normal.
Why? It just means that the template becomes responsible for any indenting and newlines within the end (|>) and start ( <|) tokens.
---
If you have any feature requests or bug reports, please raise them on https://github.com/sempare/sempare-delphi-template-engine/issues