.Template

ISHML's text generation API facilitates the creation of complex text generation objects using a templating system based on JavaScript's template literal notation. Specifically, ishml.Template is a tag function that may be called with either template literal notation or standard function call notation. Instead of directly returning text, however, ishml.Template returns an instance of ishml.Phrase. The template defines the phrase; the phrase generates the text. See the text generation tutorial for detailed examples of templates in use.

It is common practice to assign ishml.Template to the underscore variable to make the templates easier to read. The API documentation follows this convention.

The built-in template prefixes require ishml.js. The English language prefixes require en-us.js.

Place the following scripts near the end of the HTML document, before the closing </body> tag. Then add your own script below this script.

<script src="{{ site.ishml }}"></script>			
<script src="{{ site.en_us }}"></script>
<script>
	var _ = ishml.Template 
	//etc.
</script>

_`template literal`
_(value1[, ...[, valueN]])
_([value1[, ...[, valueN]]])

Returns a new unmodified instance of ishml.Phrase. When the .say() method is called, the elements of phrase's array are concatenated together. This is the default text generation provided by the baseline template.

Prefixes

The baseline template also exposes a collection of additional templates through its properties. These templates are called prefixes and modify the default text generation behavior. Prefixes work a bit differently than standard functions. An unlimited number of prefixes may by chained together with dot notation to apply layer upon layer of modifications. However, only the last prefix in the chain takes arguments. This last prefix generates a ishml.Phrase and then that phrase is passed as the argument to the next to last prefix in the chain, which generates a new phrase. The process continues all the way up to the front of the chain. Therefore, prefixes are applied from right to left starting with the prefix closest to the left parenthesis or backtick. Chaining permits the creation of complex phrases from an uncluttered single line of code.

See the text generation tutorial for examples of prefix chaining.

.a

Modifies a phrase to prepend an indefinite article, a or a, of each item in the phrase's array based on whether the item is pronouced with an initial vowel sound according to standard American English. The .a is identical to .an.

.A

Modifies a phrase to prepend a capitalized indefinite article, A or An, of each item in the phrase's array based on whether the item is pronouced with an initial vowel sound according to standard American English. The .A is identical to .An.

.an

Modifies a phrase to prepend an indefinite article, a or an, of each item in the phrase's array based on whether the item is pronouced with an initial vowel sound according to standard American English. The .an prefix is identical to .a.

.An

Modifies a phrase to prepend a capitalized indefinite article, A or An, of each item in the phrase's array based on whether the item is pronouced with an initial vowel sound according to standard American English. The .An prefix is identical to .A.

.cap

Modifies a phrase to capitalizes the first letter of each item in the phrase's array.

.cycle

Modifies a phrase to select each item of the phrase's array in order.

.ed

Modifies a phrase to convert each item in the phrase's array to past tense according to standard American English.

.e

Modifies a phrase to convert each item (verb) in the phrase's array to a past participle according to standard American English.