CodeSamplePanel
Domain · API DocDark-themed panel showing code samples in multiple languages with tab switching and a one-click copy button.
cURL
JavaScript
curl -X GET https://api.example.com/users \
-H 'Authorization: Bearer <token>'
<%- include('modules/domain/api-doc/CodeSamplePanel', {
samples: [
{ lang: 'curl', label: 'cURL', source: "curl -X GET https://api.example.com/users \
-H 'Authorization: Bearer '" },
{ lang: 'javascript', label: 'JavaScript', source: "const res = await fetch('/users', { headers: { Authorization: 'Bearer ' } });" },
]
}) %>
<%
var _samples = locals.samples || [];
if (!_samples.length) { return; }
var _csid = 'csp_' + Math.random().toString(36).slice(2, 10);
%>
<% _samples.forEach(function(s, i) {
var active = i === 0;
%>
<% }); %>
<% _samples.forEach(function(s, i) {
var active = i === 0;
%>
<%= s.source %>
<% }); %>