Velocity - expression as argument?

Method as an argument DOES work (as opposed to what I thought first), but it doesn t make sense in this case:

$space.key.substring($space.key.length())

What I actually wanted:

$space.key.substring($space.key.length() - 2)

But the expression as an argument doesn t work. Should it?
Thanks
G.

2 answers

1 accepted

Accepted Answer
1 vote
## @noparams
#set($len = $space.key.length() - 2)
$space.key.substring($len)

Workaround with var

not testet but try

$space.key.substring(${space.key.length()} - 2)

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Aug 21, 2018 in Agile

What's new this quarter in Confluence Server - August 2018

Hello Atlassian Community! My name is Ada , and I'm the Product Marketing Manager for Confluence Server at Atlassian. If you missed   our last post, we're transitioning to quarterly updates&nb...

153 views 0 1
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you