Closed edwinyzh closed 1 year ago
var lctx:=template.context;
lctx.addfunctions(TTmplFunctions);
ltpl := template.parse(lctx, '....');
writeln(Template.Eval(lCtx, lTpl, ldata));
does the above make sense?
Ah, sorry, I didn't appreciate the issue you highlighted...
All helpers are expected to be functions... so they should return something.
maybe change SetThemeData to something like: class function SetThemeData(const aThemeData: TThemeData) : string; static;
and return empty string for now.
I think I can fix this to do so automatically.
Making SetThemeData to return string
helped. Maybe in the future to remove this limit ;)
Thanks!
The issue in supporting procedures in the template engine is that it starts to violate the core principle. Data should be presented to the template engine rather than the template engine mutating and updating data. Functions should generally be used for formatting purposes.
Supporting procedures can be done however.
Support will be released shortly
I'm trying to use custom utility functions, but stuck at the
AddFunctions
stage and have no clue...The details of the error: main thread ($bbc): 005392a0 +000 prog1.exe System.Rtti 4643 +0 TRttiType.GetHandle 0053a194 +004 prog1.exe System.Rtti 4841 +1 TRttiType.GetTypeKind 014b0467 +067 prog1.exe Sempare.Template.Functions 105 +1 TTemplateFunctions.Add 014b0682 +062 prog1.exe Sempare.Template.Functions 131 +3 TTemplateFunctions.AddFunctions 01fa3fca +11a prog1.exe SempareTemplateSiteCompilerImplU 826 +16 TSempareTemplateSiteCompilerImpl.AfterConstruction
The class in question: