#1 2014-08-06 10:13:42

Pyjama
Member
Registered: 2014-07-07
Posts: 9

Mustache - Sections

Hi there!

I have a question about sections in mustache.

For example, I have the following code as a template:

{{#names}}
The friend of {{name}} is {{friend}}.
{{/names}}

It should be very easy. There is a name who got a friend.

I have more than one name with different friends, how can I realize that?

TDocVariant.New(doc);
doc.names := true;
doc.name := 'Peet'; // Here I want to get more names
doc.friend := 'James'; // and more friends

mustache := TSynMustache.Parse(myHTML);
html := mustache.Render(doc);

I want to have some output like this:

The friend of Peet is James.
The friend of Olaf is Tom.
The friend of...

How can i realize that? smile

Offline

#2 2014-08-06 14:03:26

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

Re: Mustache - Sections

Juste define names as one array of name/friend objects.

Offline

Board footer

Powered by FluxBB