$extends again

9 views
Skip to first unread message

Jon Stevens

unread,
Feb 6, 2012, 6:38:42 PM2/6/12
to cambridge...@googlegroups.com
Ok, using the latest code. Thanks for fixing. 

Now I'm trying to do something else with $extends...

I've got a structure like this:

WEB-INF/tmpl/_body.html
WEB-INF/tmpl/tour/tour.html

In tour.html:

<!--$extends _body.html -->

That works. That seems utterly broken to me though since I _could_ have tour/_body.html. Wouldn't they conflict at that point?

It seems like in my case, it should be:

<!--$extends ../_body.html -->

But that causes this error:

Caused by: cambridge.TemplateLoadingException: java.io.FileNotFoundException: ...../war/WEB-INF/tmpl/../_body.html (No such file or directory)
at cambridge.FileTemplateLoader.parseTemplate(FileTemplateLoader.java:80)
at cambridge.FileTemplateLoader.parseTemplate(FileTemplateLoader.java:73)
at cambridge.DirectoryTemplateLoader.parseTemplate(DirectoryTemplateLoader.java:59)

It seems to me like whatever is loading those templates should be resolving .. in paths better.

Thoughts?

jon

Erdinc Yilmazel

unread,
Feb 6, 2012, 7:21:04 PM2/6/12
to cambridge...@googlegroups.com
The paths in the extends clause should be relative to the root path of the template loader you have created. (I'm not saying this design is correct, just saying it is the way it should work with the current code base).

If you are using a DirectoryTemplateLoader and your base templates folder is /war/WEB_INF/tmpl/ here is whats going to happen:

extends _body.html should match /war/WEB_INF/tmpl/_body.html.
extends tour/_body.html should match /war/WEB_INF/tmpl/tour_body.html

This applies to any template file that is created using this DirectoryTemplateLoader regardless of where they are put. You are not giving cambridge relative paths to your other templates here.

If you are using a FileTemplateLoader though, it is different. The links are going to be relative to the template file itself this time.

I hope this clears some confusion.

Thanks,

Erdinc

Jon Stevens

unread,
Feb 6, 2012, 7:30:17 PM2/6/12
to cambridge...@googlegroups.com
Thanks Erdinc, that makes more sense.

jon
Reply all
Reply to author
Forward
0 new messages