You are not logged in.
Hello ab,
The helper being used in this form:
{{{helperA {src: "folder1/file1.jpeg", alt: "some text"}}}}
If I understand the document correctly, this part, the JSON string will be passed to helperA by the engine:
{src: "folder1/file1.jpeg", alt: "some text"}
is supposed to be passed into the TMyClass.HelperA method below:
The helper function registered with TSynMustache.HelperAdd is defined as something like:
procedure TMyClass.HelperA(const Value: variant; out result: variant);
begin
// here I expect the "Value" parameter contains the JSON string passed to the helper,
// but the Delphi debugger shows that the "Value" parameter is null
end;
However, the debugger shows that the "Value" parameter is null.
Any hint? Thanks.
Last edited by edwinsn (2019-12-20 03:44:15)
Delphi XE4 Pro on Windows 7 64bit.
Lazarus trunk built with fpcupdelux on Windows with cross-compile for Linux 64bit.
Offline
I fixed the issue, a github PR is coming
Delphi XE4 Pro on Windows 7 64bit.
Lazarus trunk built with fpcupdelux on Windows with cross-compile for Linux 64bit.
Offline
@ab,
the gihtub PR is here: https://github.com/synopse/mORMot/pull/260
Please review and make changes as needed. Thanks.
Delphi XE4 Pro on Windows 7 64bit.
Lazarus trunk built with fpcupdelux on Windows with cross-compile for Linux 64bit.
Offline
Thank you ab! I think you can write the tests better, and I'll check them once you are done, so that maybe next time my PR will also include some tests.
Delphi XE4 Pro on Windows 7 64bit.
Lazarus trunk built with fpcupdelux on Windows with cross-compile for Linux 64bit.
Offline
Your implementation didn't properly handle nested objects and such.
I also added some regression tests.
Please check https://synopse.info/fossil/info/f6cd3f162d
Online
Thanks for the new implementation, ab, I actually didn't take into account nested JSON objects.
I tested the new version and found an issue that's also exist with my implementation (which I didn't notice until now).
The issue is with tags with 3 brackets, in that case the result will include an extra unwanted '}' at the end of the rendering result.
I guess the following test can reveal the issue.
helpers := mustache.HelpersGetStandardList(['jsonhelper'], [MustacheHelper]);
mustache := TSynMustache.Parse('{{{jsonhelper {a:"a",b:10}}}}');
html := mustache.RenderJSON('', nil, helpers);
Check(html='a=a,b=10');
Delphi XE4 Pro on Windows 7 64bit.
Lazarus trunk built with fpcupdelux on Windows with cross-compile for Linux 64bit.
Offline
You are right.
Please check https://synopse.info/fossil/info/96a87d13b0
Online
I confirm it's fixed now! Happy holidays!
Delphi XE4 Pro on Windows 7 64bit.
Lazarus trunk built with fpcupdelux on Windows with cross-compile for Linux 64bit.
Offline