Skip to content

Commit 91b081f

Browse files
committed
fix: apic-348 render json table for example when value is json
1 parent 17d323e commit 91b081f

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/ApiExampleRender.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ export class ApiExampleRender extends LitElement {
264264
return true;
265265
}
266266
/**
267-
* Computes whether passed value is a valig JSON object, when component is
267+
* Computes whether passed value is a valid JSON object, when component is
268268
* marked to parse JSON data.
269269
* @param {Boolean} isJson [description]
270270
* @param {String} value Current example value
@@ -525,10 +525,14 @@ export class ApiExampleRender extends LitElement {
525525
}
526526

527527
_renderExample(example) {
528+
const exampleValue = example.value;
529+
const isJsonExampleValue = this._computeIsJson(this.isJson, exampleValue);
530+
const renderJsonTable = this.renderTable && isJsonExampleValue;
531+
528532
return html`
529533
${this._headerTemplate(example)}
530-
${this.renderTable ? html`<json-table .json="${example.value}"></json-table>`: ''}
531-
<div class="code-wrapper ${example.isScalar ? 'scalar': ''}" part="code-wrapper, example-code-wrapper" ?hidden="${this.renderTable}">
534+
${renderJsonTable ? html`<json-table .json="${exampleValue}"></json-table>`: ''}
535+
<div class="code-wrapper ${example.isScalar ? 'scalar': ''}" part="code-wrapper, example-code-wrapper" ?hidden="${renderJsonTable}">
532536
<code id="output" class="markdown-html" part="markdown-html" language-xml=""></code>
533537
</div>`;
534538
}

0 commit comments

Comments
 (0)