18.7 Template strings

Note: Added in G-Cows version 1.9

Synopsis

fill(template-string, variables);

fill(template-string, array-varaibles []);

Description

Fills template-string with one or more variables. Every occurrency of %s inside template-string is replaced by one of the variables.

Example

fill ("Meat %s murder --The Smiths", "is")

replaces %s with is and returns Meat is murder.

Example 2

fill ("Flesh eating is unprovoked murder. --%s %s", "Benjamin", "Franklin")

replaces first %s with Benjamin, the second %s with Franklin and returns Flesh eating is unprovoked murder. --Benjamin Franklin.

Example 3

generic_link = '<a href="%s/%s.html">%s</a>';
section      = 'vegetarianism';
subsection   = 'health';
descr        = 'Vegetarianism & health';
link         = fill (generic_link, section, subsection, descr);
print (link);

displays <a href="vegetarianism/health.html">Vegetarianism & health</a>

This manual can be downloaded from http://www.g-cows.org/.