You are not logged in.
Pages: 1
I noticed the following test code didn't work:
mustache := TSynMustache.Parse( stringtoutf8('1+3={{tval}} - is it 4? {{#if tval=45}}yes!{{/if}}'));
s := utf8tostring(mustache.RenderJSON( stringtoutf8('{ "tval":45}'), nil, Mustache.HelpersGetStandardList ));
debug_alert(s);
.. turned out the problem was in SynMustache.pas on line 1221:
valArr.InitArray([GetValueCopyFromContext(Copy(nam,1,j-1)),
Copy(nam,j,k-j),GetValueCopyFromContext(Copy(nam,k+1,maxInt))],JSON_OPTIONS[true]);
needs to be:
valArr.InitArray([GetValueCopyFromContext(Copy(nam,1,j-1)),
Copy(nam,j,k-j),GetValueCopyFromContext(Copy(nam,k,maxInt))],JSON_OPTIONS[true]);
Thanks for the library! I use it together with DCEF3 to generate all kind of reports in my application!
Regards,
Stefan
Offline
... and line 1171 in TSynMustacheContextVariant.GetValueCopyFromContext :
if (ValueName='') or (ValueName[1] in ['1'..'9','"','{','[']) or
(ValueName='true') or (ValueName='false') or (ValueName='null') then
... need to include the "0" character :
if (ValueName='') or (ValueName[1] in ['0'..'9','"','{','[']) or
(ValueName='true') or (ValueName='false') or (ValueName='null') then
... or else "{{#if tval=0}} wouldn't work!
Offline
Please check http://synopse.info/fossil/info/435bfce8b3
I've included your fix, and added the corresponding regression tests.
Thanks for the feedback!
Offline
Looks good! Thank you Arnaud!
Offline
Pages: 1