Thanks
]]>procedure MyTranslate(var English:String);
begin;
if SameText(English,'MyVar')
then begin;
English:=CalcIt;
end;
end;
?
Then it can even insert more mustache code and run a second parse/render cycle to render that.
Regards
]]>Filters are convenient, and perhaps easier to implement.
But is client-side templating really needed for us?
If we want the same exact templates on both client & server, then SynMustache + mustache.js should be good.
Then we may be able to add any custom syntax on the server side. If we can be somewhat compatible with Handlebars, without breaking Mustach syntax, it could be good enough.
Could be something similar to https://github.com/jehugaleahsa/mustache-sharp#readme
What do you think?
]]>"I'm wondering if in SynMustache does exists the possibility to call a formatting function inside the template.
This is because if I need presentation logic implemented in Delphi (because mustache is logicless) I have to prepare data before to send it to the renders.
Something like:
in Delphi
Mustache.AddTemplateFunction('dollars', function (Values: TArray<TValue>): String
begin
Result := Format(Values[1].AsString, [Values[0].AsDouble]);
end);
and in the template
{{mydata|dollars:'$ ###0.00'}}
N.B. In the template I've used the angularjs filters syntax, but just to be clear (https://docs.angularjs.org/api/ng/filter/filter)
I know there isn't such concept in Mustache, but this is a nice addition to the standard IMHO, and doesn't break it."
Arnaud suggest that handlebars syntax could be also a viable solution.
Both angularjs and handlebars syntax are nice, coherent and powerful. As my personal favourite, I'd like to have angularjs syntax, but probably makes sense to implement handlebars syntax. So my vote goes for Handlebars syntax.
Any other POV?
]]>