stringtemplate4 icon indicating copy to clipboard operation
stringtemplate4 copied to clipboard

STGroup.getTemplateNames() only returns templates defined in the group

Open bmc opened this issue 8 years ago • 0 comments

From my tests, it appears that calling getTemplateNames() on an instantiated STGroupFile object only returns the names of templates that are defined in the group (.stg) file, itself, ignoring any templates defined in subfiles pulled in via import. This behavior appears in my tests against v4.0.8.

Is this intended behavior? If so, what's the call to load() inside getTemplateNames() doing, if not loading imports?

If it's not intended behavior, then perhaps this is a bug...

Tested with the following files:

/tmp/st/foo.stg:

delimiters "%", "%"
import "parens.st"

bar(args) ::= <<foo>>

/tmp/st/parens.st:

parens(args) ::= <<
(%args; separator=","%)
>>

Code

STGroupFile g = new STGroupFile("/tmp/st/foo.stg");
System.out.println(g.getTemplateNames()); // Prints: [/bar]
ST t = g.getInstanceOf("parens"); // retrieves the "parens" template, as expected
System.out.println(g.getTemplateNames()); // Prints: [/bar]

bmc avatar Feb 14 '17 04:02 bmc