ui
Direct access to the HTML transcript.
Member Summary
Public Members | ||
public |
createTemplate(src: function(src: string): function): * You may replace this property if you want to use a template language other than Nunjucks. |
|
public |
director: * |
|
public |
MarkdownIt instance used to render Markdown. |
|
public |
nunjucks: * nunjucks instance used to render templates. |
Method Summary
Public Methods | ||
public |
addTemplateContext(fns: Map<string, function>) Make the given objects or values available to the template context. |
|
public |
addTemplateGetters(fns: Map<string, function>) Whenever a template is rendered, evaluate all these functions and make their return values available to the template context. |
|
public |
clear() Remove all content from the transcript and start fresh. |
|
public |
presentChoices(arrayOfSituationIdsOrTags: string[]): * Given an array of tags or situation IDs (can be both in the same array), present the relevant choices in the transcript using the logic in model.interpretChoices. |
|
public |
promptInput(options: Map<string, *>): Promise<string> Force the user to enter some text to continue. |
|
public |
renderMarkdown(text: string, inline: Boolean): * Render the given Markdown text to HTML. |
|
public |
renderMarkdownTemplate(src: string, args: Map<string, *>, inline: Boolean): * Process the text as a template, render the resulting Markdown to HTML, and return the result. |
|
public |
renderMarkdownTemplateMaybeInline(src: string, args: Map<string, *>, inline: Boolean): * Like renderMarkdownTemplate, but automatically sets |
|
public |
renderTemplate(src: string, args: Map<string, *> | null): * Process the text as a template and return the result. |
|
public |
Render the given HTML as a template and write it to the transcript WITHIN THE CURRENT SECTION. |
|
public |
Render the given HTML as a template and write it to the transcript. |
|
public |
writeMarkdown(markdown: string, args: Map<string, *>) Render the given string as a template, render the resulting Markdown as HTML, and write it to the transcript. |
Public Members
public createTemplate(src: function(src: string): function): * source
You may replace this property if you want to use a template language other than Nunjucks.
It is a function that takes a string and returns a function that takes attrs and returns a rendered string. Like this:
(src) => (attrs) => render(src, attrs)
public director: * source
public md: MarkdownIt source
MarkdownIt instance used to render Markdown. You may use it to register additional plugins.
public nunjucks: * source
nunjucks instance used to render templates. You may use it to add custom tags, filters, or globals. (See the "Environment" section of this page.)
Public Methods
public addTemplateContext(fns: Map<string, function>) source
Make the given objects or values available to the template context.
public addTemplateGetters(fns: Map<string, function>) source
Whenever a template is rendered, evaluate all these functions and make their return values available to the template context.
All template getters are called whenever you render any template.
Example:
// If you add a getter like this:
jumbogrove.jumbogrove('#game', {
init: (model, ui) => {
ui.addTemplateGetters({
randomNumber: () => Math.random()
});
}
});
// Then you may use it in a template like this:
`
{{ randomNumber }}
`
// and it will show the function's return value (in this case, a random
// number 0-1).
public presentChoices(arrayOfSituationIdsOrTags: string[]): * source
Given an array of tags or situation IDs (can be both in the same array), present the relevant choices in the transcript using the logic in model.interpretChoices.
Params:
Name | Type | Attribute | Description |
arrayOfSituationIdsOrTags | string[] | Array of strings containing either |
Return:
* |
public promptInput(options: Map<string, *>): Promise<string> source
Force the user to enter some text to continue.
public renderMarkdown(text: string, inline: Boolean): * source
Render the given Markdown text to HTML. Automatically dedents the text to the minimum indent level.
Return:
* |
public renderMarkdownTemplate(src: string, args: Map<string, *>, inline: Boolean): * source
Process the text as a template, render the resulting Markdown to HTML, and return the result. Automatically dedents the text to the minimum indent level.
Return:
* |
public renderMarkdownTemplateMaybeInline(src: string, args: Map<string, *>, inline: Boolean): * source
Like renderMarkdownTemplate, but automatically sets inline
flag based on
presence of line breaks.
Return:
* |
public renderTemplate(src: string, args: Map<string, *> | null): * source
Process the text as a template and return the result.
Return:
* |
public write(markdown: string, args: Map<string, *>) source
Render the given HTML as a template and write it to the transcript WITHIN THE CURRENT SECTION. If you are writing HTML from inside an action function, this is probably what you want.
public writeHTML(html: string, args: Map<string, *>) source
Render the given HTML as a template and write it to the transcript. Links are automatically bound to actions and situation transitions.
The output comes after ALL HTML in the current section, If you are presenting a choice, the HTML will be written BELOW the choice.
public writeMarkdown(markdown: string, args: Map<string, *>) source
Render the given string as a template, render the resulting Markdown as HTML, and write it to the transcript.
The output comes after ALL HTML in the current section, If you are presenting a choice, the text will be written BELOW the choice.