dafky2000 / simplectemplate

Simple C Template library to expand placeholders in a template string, simple alternative to mustache.github.io that doesn't require JSON as data input.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Data "sections"

dafky2000 opened this issue · comments

Suggested by @allinurl allinurl/goaccess#685

Would be handy for repeating the same block, I am thinking something like this

const char *data[] = {
	"data.url[]", "https://google.ca/",
	"data.url[]", "https://google.com/",
	"data.url[]", "http://google.ca/",
	"data.text[]", "https://google.ca/",
	"data.text[]", "https://google.com/",
	"data.text[]", "http://google.ca/",
};

{{logic.repeat <a href="{{data.url[]}}" >{{data.link[]}}</a>}}

Obviously, each repeated block would require the same index of each data.url[] and data.text[]. simplectemplate would simply select the data with the matching index of the loop. If the placeholder index doesn't exist than we simply use the first found instance of the placeholder.

Thought: Could also support allowing hardcoded index in the const char* data[] array. Like data.text[3].

Since we have nested placeholders this is dependent on #22

Similar to #23 (comment)

{{#data.key}}
   If there are multiple data.key's than we will loop with this data inserting each {{item}}
{{/data.key}}