website/_includes/code.html

27 lines
1.1 KiB
HTML

{% capture samplecode %}{% include_relative {{include.file}} %}{% endcapture %}
{% if include.k8slink %}{% capture ghlink %}https://raw.githubusercontent.com/kubernetes/kubernetes/blob/{{page.githubbranch}}{{include.k8slink}}{% endcapture %}{% endif %}
{% if include.ghlink %}{% capture ghlink %}https://raw.githubusercontent.com/kubernetes/kubernetes.github.io/{{page.docsbranch}}{{include.ghlink}}{% endcapture %}{% endif %}
{% capture mysample %}
```{{include.language}}
{{ samplecode | raw | strip }}
```
{: id="{{include.file | handleize}}"}
{% endcapture %}
<table class="includecode">
<thead>
<tr>
<th>
{% if ghlink %}<a href="{{ghlink}}" download="{{include.file}}">{% endif %}
<code>{{include.file}}</code>
{% if ghlink %}</a>{% endif %}
<img src="/images/copycode.svg" style="max-height:24px" onclick="copyCode('{{include.file | handleize}}')" title="Copy {{include.file}} to clipboard">
</th>
</tr>
</thead>
<tbody>
<tr>
<td>{{ mysample | markdownify }}</td>
</tr>
</tbody>
</table>