String concatenation in stringtemplate

821 views Asked by At

I'm trying to make a lookup to a hash table m.notes using concatenated value of position.qid and literal ".qid" like this:

$tag(name="itemId", content=m.notes.(position.qid".qid").itemId)$

I tried different options, but I get runtime error. Can someone correct my syntax?

3

There are 3 answers

0
maheeka On

Not sure whether such concatenation is possible in string template. Why don't you use a different method that could do the concatenation and return the value.

e.g: position.fullQid instead of position.qid

where,

public String getFullQid(){
return getQid() + ".qid";
}
0
bigchamelon On

in template group, I can do like this, first, define a concantenate template: concantenate(substr)::="" then use as following (concantenate([position.qid,".qid"]))

1
sudheeshix On

Put the 2 items in an array. StringTemplate concatenates all items in an array (or as they call it, a multi-valued-attribute) when it executes a ToString() on it.

[position.qid, ".qid"]

So, if position.qid evaluates to "hello", this expression would become hello.qid.