stringtemplate4 icon indicating copy to clipboard operation
stringtemplate4 copied to clipboard

Cloning template multiple times leads to change of attribute type

Open jcordes73 opened this issue 9 years ago • 0 comments

When cloning a template at least two times, the type of an attribute changes to AttributeList.

Below you can find a simple test-case:

ST t1 = new ST("$key$");

ST t2 = new ST(t1);
t2.add("key1", "value1");
t2.add("key2", "value2");
assertFalse(t2.getAttribute("key1") instanceof AttributeList);

ST t3 = new ST(t1);
t3.add("key1", "value1");
t3.add("key2", "value2");
assertFalse(t3.getAttribute("key1") instanceof AttributeList);

I had some issues with this in my templates, so for now I'm using

templateGroupDir.getInstanceOf(templateName);

to create a new instance of a template instead of cloning.

I have expected these two approaches to lead to identical results. Is my expectation wrong?

jcordes73 avatar Feb 14 '15 22:02 jcordes73