forked from jenkinsci/design-library-plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcode.jelly
More file actions
48 lines (45 loc) · 2.09 KB
/
code.jelly
File metadata and controls
48 lines (45 loc) · 2.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<?jelly escape-by-default='true'?>
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define" xmlns:l="/lib/layout">
<st:documentation>
Displays a copyable code snippet.
<st:attribute name="code">
Code snippet to be displayed if and only if "file" is not set.
</st:attribute>
<st:attribute name="callback">
JavaScript function to be called when the "Execute code" button is clicked.
If "code" attribute is set, these two attributes should be in sync ("code" cannot be inline JS anymore due to CSP).
</st:attribute>
<st:attribute name="file">
File containing the code snippet to be displayed.
If the "callback" attribute is set, the file will be referenced in a script tag, so that it can be invoked.
</st:attribute>
<st:attribute name="language" use="optional">
Defaults to 'xml'.
</st:attribute>
<st:attribute name="previewable" type="boolean" />
</st:documentation>
<div class="jdl-component-code">
<pre class="jdl-component-code__code">
<code class="language-${language != null ? language : 'xml'} ${file != null ? 'sample-remote' : ''}" data-component-name="${it.class.simpleName}" data-sample="${file}" data-executable="${callback != null}">
${code}
</code>
</pre>
<div class="jdl-component-code__controls">
<div>
<d:invokeBody />
<j:if test="${callback != null}">
<!-- This only works if the 'code' attribute is set -->
<button class="jenkins-button jenkins-button--tertiary jenkins-!-build-color callback-button" data-callback="${callback}" tooltip="${%Execute code}">
<l:icon src="symbol-play" />
</button>
</j:if>
<j:if test="${previewable == 'true'}">
<a href="${file.replace('.jelly', '')}" class="jenkins-button jenkins-button--tertiary" tooltip="${%Preview in new tab}" target="_blank">
<l:icon src="symbol-open-outline plugin-ionicons-api" />
</a>
</j:if>
<l:copyButton text="${code}" clazz="jenkins-button--tertiary" />
</div>
</div>
</div>
</j:jelly>