-
Content Count
111 -
Joined
-
Last visited
-
Days Won
2
Posts posted by darnocian
-
-
I just looked at the tests... mostly testing with #$A. 😉 But made a test to replicate the issue.
-
Thanks for the report.
Could you please raise the issues on https://github.com/sempare/sempare-delphi-template-engine/issues
I'll check it out. A double #$D would not be ideal. The #$A is more easily noticeable, but most of the stuff I used was HTML where this would have been ignored.
-
Hi.
I use the Rad Studio ‘Build Tools’ functionality to do some code generation. Using a config file and my ‘build tool’, associated .pas files are created during during compilation.
Do you know if there is a way to get the IDE to group the related files the way it does with the pas and dfm files?
Is there some config/registry setting for this or would it require a custom IDE plugin?Any insight appreciated.
-
Performance wise 100% agree with you David. It was more an example to check it out initialisation in case that was an issue.
-
I realise this is an old post...
The other thing - usually with COM, you need to CoInitialize() in each thread, and if you are a nice citizen, CoUninitialize().
To coordinate shutdown, you may also want to look at TCountdownEvent from System.SyncObjs. TCountdownEvent waits for a counter to reach zero. A signal in a thread would trigger the countdown.
Could do something like (sorry, I automatically referenced TTask.Run rather than Parallel.Async)
// This is pseudocode, so might not be 100% accurate with params var event := TCountdownEvent.Create(); event.AddCount(length(workList)); for var work in workList do begin TTask.Run(procedure begin CoInitialize(); try process(work); finally CoUninitalize(); event.signal(); end; end; end; event.WaitFor(INFINITE);
With the above code, if run from a UI would still block, so that should also be threaded if the UI is meant to remain responsive.
-
A new version (v1.3.1) is available on github with bug fixes (https://github.com/sempare/sempare-delphi-template-engine)
Hope to have the update in getit shortly too.
- 1
-
-
I'd like to advertise the Sempare Template Engine for Delphi. The Sempare Template Engine for Delphi allows for flexible text manipulation. It can be used for generating email, html, source code, xml, configuration, etc.
It is available on github via https://github.com/sempare/sempare-delphi-template-engine
It is also available via Delphinus (https://github.com/Memnarch/Delphinus)
Simply add the 'src' directory to the search path to get started.
Sample usage:
program Example; uses Sempare.Template; type TInformation = record name: string; favourite_sport : string; end; begin var tpl := Template.parse('My name is <% name %>. My favourite sport is <% favourite_sport %>.'); var information : TInformation; information.name := 'conrad'; information.favourite_sport := 'ultimate'; writeln(Template.eval(tpl, information)); end.
Features include:
-
statements
- if, elif, else statements
- for and while statements
- include statement
- with statement
- function/method calls
-
expressions
- simple expression evaluation (logical, numerical and string)
- variable definition
- functions and methods calls
- dereference records, classes, arrays, JSON objects, TDataSet descendants and dynamic arrays
- ternary operator
-
safety
- max run-time protection
-
customisation
- custom script token replacement
- add custom functions
- strip recurring spaces and new lines
- lazy template resolution
- parse time evaluation of expressions/statements
- allow use of custom encoding (UTF-8 with BOM, UTF-8 without BOM, ASCII, etc)
- extensible RTTI interface to easily dereference classes and interfaces (current customisations for ITemplateVariables, TDictionary, TJsonObject)
There are numerous unit tests that can be reviewed as to how to use the various features.
Happy for all to play with it. Released under GPL and Commercial License.
Any feedback welcome.
- 8
- 3
-
statements
-
FYI. I recall that you can reference the base ptr on the underlying PyArray. Definitely coming from unmanaged code, you want to try avoid copying if you can.
C++ Boost does it quite nicely actually. I last bridged the c++ / python route a number of years ago, so with delphi it will be possible.
https://www.boost.org/doc/libs/1_64_0/libs/python/doc/html/numpy/tutorial/ndarray.html
https://github.com/boostorg/python/blob/develop/src/numpy/ndarray.cpp
inside there is from_data_impl which I think should also be an interesting reference.
-
I was very disappointed too. It seems like they are trying to force people to upgrade. Requesting pricing won't help - I've done it twice already - they simply state it is no longer available.
I appreciate it takes some time to manage packages, but is it really worth upsetting users that have been buying the product? Anyways, alternatives are available, even other programming environments were connecting to a database is not 'an enterprise feature' and is free...
ANN: Sempare Template Engine for Delphi
in Delphi Third-Party
Posted · Edited by darnocian
Yes. Use in a multi threaded environment should be totally fine. I've even used it to serve html on an indy server.
There is locking used internally when accessing some internally managed collections as required.
You can load templates on the fly and the locks ensure the state of the structures don't get corrupted. You can load/parse templates upfront or on demand safely. There is no global/shared state that should cause any issues.
There are a few different Template.Eval() overrides which allow you to use the templates that have been pre-parsed, or you can just reprocess a textual representation as required. When evaluation takes place, the state is totally independent of any other execution on other threads.