MCPcopy Create free account
hub / github.com/Monogatari/Monogatari / render

Method render

src/components/choice-container/index.ts:70–91  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

68 }
69
70 override render(): Promise<string> {
71 const choices = this.props.choices.map((choice) => {
72 const choiceText = this.engine.replaceVariables(choice.Text);
73
74 if (typeof choice.Clickable === 'function') {
75 return new Promise<string>((resolve) => {
76 this.engine.assertAsync(choice.Clickable!, this.engine).then(() => {
77 resolve(`<button data-do="${choice.Do}" ${choice.Class ? `class="${choice.Class}"` : ''} data-choice="${choice._key}">${choiceText}</button>`);
78 }).catch(() => {
79 resolve(`<button data-do="${choice.Do}" ${choice.Class ? `class="${choice.Class}"` : ''} data-choice="${choice._key}" disabled>${choiceText}</button>`);
80 });
81 });
82 }
83 return Promise.resolve(`<button data-do="${choice.Do}" ${choice.Class ? `class="${choice.Class}"` : ''} data-choice="${choice._key}">${choiceText}</button>`);
84 });
85
86 return Promise.all(choices).then((choiceButtons) => `
87 <div data-content="wrapper">
88 ${choiceButtons.join('')}
89 </div>
90 `);
91 }
92}
93
94export default ChoiceContainer;

Callers

nothing calls this directly

Calls 3

replaceVariablesMethod · 0.80
assertAsyncMethod · 0.80
allMethod · 0.45

Tested by

no test coverage detected