#1 2018-08-17 12:52:13

jaclas
Member
Registered: 2014-09-12
Posts: 215

SynMustache and RenderJSON and Args param

I try use method:

    /// renders the {{mustache}} template from JSON defined context
    // - the context is given via a JSON object, defined with parameters
    // - you can specify a list of partials via TSynMustachePartials.CreateOwned,
    // a list of Expression Helpers, or a custom {{"English text}} callback
    // - is just a wrapper around Render(_JsonFastFmt())
    // - you can write e.g. with the extended JSON syntax:
    // !   html := mustache.RenderJSON('{name:?,value:?}',[],['Chris',10000]);
    // - set EscapeInvert = true to force {{value}} NOT to escape HTML chars
    // and {{{value}} escaping chars (may be useful e.g. for code generation)
    function RenderJSON(const JSON: RawUTF8; const Args,Params: array of const;
      Partials: TSynMustachePartials=nil; Helpers: TSynMustacheHelpers=nil;
      OnTranslate: TOnStringTranslate=nil;
      EscapeInvert: boolean=false): RawUTF8; overload;

but what is Args parameter? In the above example Args is passed as empty array.

Offline

#2 2018-08-18 08:13:59

Chaa
Member
Registered: 2011-03-26
Posts: 249

Re: SynMustache and RenderJSON and Args param

Offline

#3 2018-08-18 09:07:29

jaclas
Member
Registered: 2014-09-12
Posts: 215

Re: SynMustache and RenderJSON and Args param

Look closely. See that in the RenderJSON() function the Params parameter is next to the Args parameter:

const Args,Params: array of const;

And Params parameter contains values as in FormatUTF8(). But for what is Args?

Last edited by jaclas (2018-08-18 09:46:10)

Offline

#4 2018-08-18 13:07:36

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,682
Website

Re: SynMustache and RenderJSON and Args param

The doc, as stated by Chaa, is clear on it:

will include Args[] for every % in Format

i.e. they will be included without any JSON escape, whereas Params will make JSON escape.

Offline

Board footer

Powered by FluxBB