Skip to content

Commit f2546a9

Browse files
Simplify badge selection in jelly and allow all text to be HTML
1 parent 77164d5 commit f2546a9

File tree

1 file changed

+39
-27
lines changed
  • src/main/resources/com/jenkinsci/plugins/badge/action/BadgeAction

1 file changed

+39
-27
lines changed

src/main/resources/com/jenkinsci/plugins/badge/action/BadgeAction/badge.jelly

Lines changed: 39 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -23,32 +23,44 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
2323
THE SOFTWARE.
2424
-->
2525

26-
<?jelly escape-by-default='true'?>
26+
<?jelly escape-by-default='false'?>
2727
<j:jelly xmlns:j="jelly:core" xmlns:l="/lib/layout">
28-
<!-- icon without link -->
29-
<j:if test="${it.icon != null &amp;&amp; it.icon != '' &amp;&amp; (it.link == null || it.link == '')}">
30-
<span class="${it.cssClass}" style="${it.style}">
31-
<l:icon class="icon-sm" src="${it.icon}" alt="${it.text}" htmlTooltip="${it.text}"/>
32-
</span>
33-
</j:if>
34-
<!-- icon with link -->
35-
<j:if test="${it.icon != null &amp;&amp; it.icon != '' &amp;&amp; it.link != null &amp;&amp; it.link != ''}">
36-
<span class="${it.cssClass}" style="${it.style}">
37-
<a href="${it.link}">
38-
<l:icon class="icon-sm" src="${it.icon}" alt="${it.text}" htmlTooltip="${it.text}"/>
39-
</a>
40-
</span>
41-
</j:if>
42-
<!-- text without link -->
43-
<j:if test="${(it.icon == null || it.icon == '') &amp;&amp; (it.link == null || it.link == '')}">
44-
<span class="${it.cssClass}" style="${it.style}">
45-
${it.text}
46-
</span>
47-
</j:if>
48-
<!-- text with link -->
49-
<j:if test="${(it.icon == null || it.icon == '') &amp;&amp; it.link != null &amp;&amp; it.link != ''}">
50-
<span class="${it.cssClass}" style="${it.style}">
51-
<a href="${it.link}">${it.text}</a>
52-
</span>
53-
</j:if>
28+
<j:choose>
29+
<!-- icon -->
30+
<j:when test="${it.icon != null &amp;&amp; it.icon != ''}">
31+
<span class="${it.cssClass}" style="${it.style}">
32+
<j:choose>
33+
<!-- icon with link -->
34+
<j:when test="${it.link != null &amp;&amp; it.link != ''}">
35+
<a href="${it.link}">
36+
<l:icon class="icon-sm" src="${it.icon}" alt="${it.text}" htmlTooltip="${it.text}"/>
37+
</a>
38+
</j:when>
39+
<!-- icon without link -->
40+
<j:otherwise>
41+
<l:icon class="icon-sm" src="${it.icon}" alt="${it.text}" htmlTooltip="${it.text}"/>
42+
</j:otherwise>
43+
</j:choose>
44+
</span>
45+
</j:when>
46+
<j:otherwise>
47+
<!-- text -->
48+
<j:if test="${it.text != null &amp;&amp; it.text != ''}">
49+
<span class="${it.cssClass}" style="${it.style}">
50+
<j:choose>
51+
<!-- text with link -->
52+
<j:when test="${it.link != null &amp;&amp; it.link != ''}">
53+
<a href="${it.link}">
54+
${it.text}
55+
</a>
56+
</j:when>
57+
<!-- text without link -->
58+
<j:otherwise>
59+
${it.text}
60+
</j:otherwise>
61+
</j:choose>
62+
</span>
63+
</j:if>
64+
</j:otherwise>
65+
</j:choose>
5466
</j:jelly>

0 commit comments

Comments
 (0)