#1 2023-07-21 07:00:13

oldwired
Member
Registered: 2023-07-21
Posts: 2

Mustache get list of variables after parse

Is there a way to get a list of the variables a document contains after I parse it.

For example after

mustache := TSynMustache.Parse(
    'Hello {{name}}'#13#10'You have just won {{value}} dollars!');

I want to be able to call something like

var variablelist:=mustache.getVarList;

and receive a list that contains "name" and "value". I dug around in the code but did not find something, but I imagine mustache must have such list somewhere after parsing, so I think I must have missed something (ovious).

Offline

#2 2023-07-21 07:18:22

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

Re: Mustache get list of variables after parse

The template is indeed parsed and an internal in-memory representation is filled.

But this was not made public yet.
Please try with https://github.com/synopse/mORMot2/commit/a2adff6f
Now you can access mustache.Tags[] to retrieve the internal list.

Offline

#3 2023-07-24 11:24:25

oldwired
Member
Registered: 2023-07-21
Posts: 2

Re: Mustache get list of variables after parse

Thanks, that works for me.
Now I'm a bit embarrased that I did not find the ftags while digging around.

Offline

Board footer

Powered by FluxBB