Key concepts

What are kiwi's key concepts?

The kiwi language is extremely small and simple, with just two key concepts:

Tags

Tags are a core feature of kiwi, enabling it to retrieve data from a variety of sources (XML documents, Excel spreadsheets, SQL databases, etc.) and insert it into a document. For example, the following tag (represented by curly braces) will retrieve a value named product title:

{product title}

In simple usage, kiwi's tag substitution capabilities resemble the mail merge facility found in Office applications.

[TO DO: straighten out following lines]

Tags understand how to obtain and output data.

The true power of kiwi comes from the rules that are added to the system.

If tags are kiwi's grammar, rules are its vocabulary.

However, kiwi tags are capable of much more, thanks to kiwi's other core feature: its flexible, extensible rules system.

Rules

Rules are kiwi language plugins that allow users to customize and extend kiwi's basic behavior to manipulate their data and documents in many different ways. Kiwi provides a standard (though optional) library of general-purpose data manipulation (change case, find and replace, etc.) and decision-making rules.

For example, the following tag uses a case rule to convert the product name to all-uppercase text before it's inserted:

{product title @ case (upper)}

Kiwi's rules system is fully extensible. Existing libraries of rules can be imported and used, and users can create their own rules too. For example, to define a rule named short date that outputs the current date in a desired format (e.g. JUL 22, 2015):

define rule (short date, 
  (datestamp ("%b %d, %Y", none), case (upper))
)

Once the short date rule is added to kiwi, a tag like this:

{@ datestamp ("%b %d, %Y", none), case (upper)}

can be reduced to this:

{@ short date}

Custom rules can be a great time and space saver when applying the same combinations of rules many times over. Template authors, for example, can use this feature to build and manage collections of "brand rules" that describe the font, size, and color requirements for every piece of text that goes into an artwork.

[[TO DO: need to include a sentence or two on kiwi file format(s) as .kiwi files containing rule commands a standard way for users to define [e.g.] brand-specific templating rules, job rules, etc.; simplest may be to use tutorial project's job-rules and template-rules folders as examples of how .kiwi files containing custom rules can be made available for use in iki and template respectively ]]