MCPcopy Index your code
hub / github.com/rapi-doc/RapiDoc / renderExample

Method renderExample

src/components/api-request.js:278–297  ·  view source on GitHub ↗
(example, paramType, paramName)

Source from the content-addressed store, hash-verified

276 }
277
278 renderExample(example, paramType, paramName) {
279 return html`
280 ${paramType === 'array' ? '[' : ''}
281 <a
282 part="anchor anchor-param-example"
283 style="display:inline-block; min-width:24px; text-align:center"
284 class="${this.allowTry === 'true' ? '' : 'inactive-link'}"
285 data-example-type="${paramType === 'array' ? paramType : 'string'}"
286 data-example="${example.value && Array.isArray(example.value) ? example.value?.join('~|~') : (typeof example.value === 'object' ? JSON.stringify(example.value, null, 2) : example.value) || ''}"
287 title="${example.value && Array.isArray(example.value) ? example.value?.join('~|~') : (typeof example.value === 'object' ? JSON.stringify(example.value, null, 2) : example.value) || ''}"
288 @click="${(e) => {
289 const inputEl = e.target.closest('table').querySelector(`[data-pname="${paramName}"]`);
290 if (inputEl) {
291 inputEl.value = e.target.dataset.exampleType === 'array' ? e.target.dataset.example.split('~|~') : e.target.dataset.example;
292 }
293 }}"
294 > ${example.printableValue || example.value} </a>
295 ${paramType === 'array' ? '] ' : ''}
296 `;
297 }
298
299 renderShortFormatExamples(examples, paramType, paramName) {
300 return html`${examples.map((x, i) => html`

Callers 2

Calls 1

htmlFunction · 0.85

Tested by

no test coverage detected