[stringtemplate-interest] getting rid of StringTemplateGroupLoader

Terence Parr parrt at cs.usfca.edu
Mon Nov 9 12:12:31 PST 2009


On Nov 8, 2009, at 11:18 PM, Jonathan Buhacoff wrote:
>> a.getInstanceOf("/AdminView/misc/leftgutter");
>> a.getInstanceOf("/AdminView/search");
>
> I think it should be a.getInstanceOf("/misc/leftgutter") and  
> a.getInstanceOf("/search") , omitting the group "name".  I think the  
> only useful place for a group name is in error logs.

Ooops! you are so right. duh.

> If I write STGroup a = new STGroupURL("http://my.server.net/path/ 
> to"), I wouldn't want to later write a.getInstanceOf("http://my.server.net/path/to/misc/leftgutter 
> ");  ... I'd want to just write a.getInstanceOf("/misc/leftgutter")  
> and not worry about where it's actually coming from.
>
> The loader could be a database loader like STGroup a = new  
> STGroupQuery(myDataSource, "SELECT content FROM template WHERE  
> filename=?")  where filenames can very well be "paths" like "/misc/ 
> leftgutter" or "/search"  (and it cleverly completes relative paths  
> based on the complete name of the current template, just like a  
> filesystem would).

Yep and we need one for resource files.

> Actually, I also have SMB, FTP/SFTP, and a few others ready to go as  
> soon as this API is finalized.

sure. now it's up to developer.

>> It will look in subdir misc to find leftgutter.st. It will look for
>> search.st in root dir AdminView. Notice that now we use '/' on the
>> front to mean absolute start from the root. Without the / on the  
>> front
>> it looks in the surrounding group's directory. If we template x says
>> <foo()> ST would look in x's associated directory for foo.
>
> How about use leading / for looking in the "root" of the current  
> group, and use no leading / to indicate relative to the current  
> template, wherever it resides in the hierarchy?

yep, that's what i meant.

> so in the file /misc/leftgutter,  if it wants to refer to a  
> neighboring template /misc/kingpin it can just say <kingpin()> and  
> that would resolve to /misc/kingpin.

correct.

Ter


More information about the stringtemplate-interest mailing list