Pergunta

I have a velocity template (in a Confluence user macro) that looks like:

## This macro takes a jiraissues macro in the body with "Show Total Only" configured to TRUE.
## It then parses the return and puts a green check if the number returned is ZERO or a red X otherwise.
## @noparams 

#set ($start = $body.indexOf("{") + 1)
#set ($end  = $body.indexOf("}") )

Printf debugging...<br />
body.substring($start, $end) = $body.substring($start, $end) <br />

<ac:rich-text-body>
  <ac:image ac:thumbnail="false">
## BUG BUG This substring is ALWAYS zero.  Dunno why.
  #if ($body.substring($start, $end) == "0")
    <ri:url ri:value="/images/icons/emoticons/check.png" />
  #else
    <ri:url ri:value="/images/icons/emoticons/error.png" />
  #end
  </ac:image>
</ac:rich-text-body>

This template has a nested other velocity template that is configured by the user to query a DB and return the number of bugs that match some criteria. The idea is that if the number returned is ZERO, then everything is hunkydory. Otherwise, well... you get the picture.

Now, there's something CLEARLY screwed up in my thinking.

  1. The $body string seems to returns something that looks like {0} issues.
  2. The {0} seems like a variable or something, but hell if I can find any documentation.

Questions

  • Which template gets evaluated first?
  • Can I even base the logic of one template on the output of another?
  • Why is my life like this? Never mind, I know the answer to that one.
Foi útil?

Solução

A string like {0} suggests that what you see isn't the actual end result, but a message template that is supposed to be filled in with real data. And to me it looks like a key used by MessageFormat, but it could be something else.

Do you happen to have the code for the inner macro as well?

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top