$extends

36 views
Skip to first unread message

Jon Stevens

unread,
Jan 19, 2012, 3:39:09 PM1/19/12
to cambridge...@googlegroups.com
Hi cambridgelovers...

I'm not sure if it is something that I'm doing wrong or not, but it seems like <!--$extends widget/foo.html --> isn't working. 

It throws this:

Caused by: cambridge.TemplateLoadingException: Could not load the extended template - On line: 1, column: 0 (Line: 1, Col: 0)
at cambridge.AbstractTemplateLoader.parseTemplate(AbstractTemplateLoader.java:45)
at cambridge.FileTemplateLoader.parseTemplate(FileTemplateLoader.java:15)
at cambridge.FileTemplateLoader.parseTemplate(FileTemplateLoader.java:78)
at cambridge.FileTemplateLoader.newTemplateFactory(FileTemplateLoader.java:39)
at cambridge.FileTemplateLoader.newTemplateFactory(FileTemplateLoader.java:31)
at cambridge.DirectoryTemplateLoader.newTemplateFactory(DirectoryTemplateLoader.java:44)
at cambridge.DirectoryTemplateLoader.newTemplateFactory(DirectoryTemplateLoader.java:39)
at st.voo.tick.util.cambridge.CambridgeViewResolver$1.render(CambridgeViewResolver.java:113)
at com.googlecode.htmleasy.provider.ViewWriter.writeTo(ViewWriter.java:84)
at org.jboss.resteasy.core.interception.MessageBodyWriterContextImpl.proceed(MessageBodyWriterContextImpl.java:117)
at org.jboss.resteasy.plugins.interceptors.encoding.GZIPEncodingInterceptor.write(GZIPEncodingInterceptor.java:63)
at org.jboss.resteasy.core.interception.MessageBodyWriterContextImpl.proceed(MessageBodyWriterContextImpl.java:123)
at org.jboss.resteasy.core.ServerResponse.writeTo(ServerResponse.java:250)
... 53 more
Caused by: Could not load the extended template - On line: 1, column: 0 (Line: 1, Col: 0)
at cambridge.parser.TemplateParser.parseExtendsDirective(TemplateParser.java:649)
at cambridge.parser.TemplateParser.parserDirective(TemplateParser.java:551)
at cambridge.parser.TemplateParser.getNode(TemplateParser.java:220)
at cambridge.parser.TemplateParser.parse(TemplateParser.java:175)
at cambridge.AbstractTemplateLoader.parseTemplate(AbstractTemplateLoader.java:41)
... 65 more
Caused by: cambridge.TemplateLoadingException: java.io.FileNotFoundException: /project/voo.st/war/WEB-INF/tmpl/widget (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)
at cambridge.model.ExtendsDirective.<init>(ExtendsDirective.java:20)
at cambridge.parser.TemplateParser.parseExtendsDirective(TemplateParser.java:647)
... 69 more
Caused by: java.io.FileNotFoundException: /project/war/WEB-INF/tmpl/widget (No such file or directory)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.<init>(FileInputStream.java:120)
at cambridge.FileTemplateLoader.parseTemplate(FileTemplateLoader.java:78)
... 73 more

Has anyone tried to put a template into a subdirectory with extends?

jon

Erdinc Yilmazel

unread,
Jan 19, 2012, 4:02:09 PM1/19/12
to cambridge...@googlegroups.com
What is the path of the template that has the $extends statement and what type of TemplateLoader are you using?

Jon Stevens

unread,
Jan 19, 2012, 4:05:50 PM1/19/12
to cambridge...@googlegroups.com
<!--$extends foo.html --> works. If I make a directory called 'widget' in the same directory where foo.html lives, then <!--$extends widget/foo.html --> doesn't work.

File templateDir = new File(ctx.getRealPath(TEMPLATE_DIR));
loader = new DirectoryTemplateLoader(templateDir, UTF_8, CHECK_INTERVAL);

cheers,

jon

Matthew Jaggard

unread,
Jan 19, 2012, 6:28:55 PM1/19/12
to cambridge...@googlegroups.com
I do it the other way around in my code without a problem. So under my main cambridge-templates directory I have "skeleton.html" then in my cambridge-templates/admin directory I have files that reference the skeleton.html - no directory needed.

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

Jon Stevens

unread,
Jan 19, 2012, 8:11:53 PM1/19/12
to cambridge...@googlegroups.com
Sure, but that isn't how I'm laid out, so I'd like to be able to specify a path in $extends.

jon

Erdinc Yilmazel

unread,
Jan 19, 2012, 10:08:20 PM1/19/12
to cambridge...@googlegroups.com
Ok this should be now fixed in github. The problem was in template parser code which parses the include and extends directives. This directive parses expressions like "filename /html/body/some/tag/path" so you don't have to include the whole file but include only certain parts of a file. It is the same for extends as well. You don't have to extend a whole template file, a template could extend only a certain part of another template.

Since this isn't a widely used and documented feature, I made a backwards incompatible change. Now if you want to include only a part of a template, you need to separate the file name and the tag selector with an @ sign. So "include foo.html /a/b/c" becomes "include foo.html @ /a/b/c".

Please get a fresh copy of TemplateParser.java see if it resolves the problem for you as well.

Thanks for reporting the issue.

Erdinc

Jon Stevens

unread,
Jan 21, 2012, 2:46:08 AM1/21/12
to cambridge...@googlegroups.com
I just cloned your repo and typed 'mvn package' and got the error below. Can I just mention again how much I f*cking hate maven? It is such a pile of shit.

jon


[INFO] ------------------------------------------------------------------------
[INFO] Building Cambridge Template Play Framework Integration 1.0
[INFO] ------------------------------------------------------------------------
[WARNING] The POM for com.playframework:playframework:jar:1.2.4 is missing, no dependency information available
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO] 
[INFO] Cambridge Template Engine ......................... SUCCESS [0.002s]
[INFO] Cambridge Template Core ........................... SUCCESS [1.816s]
[INFO] Cambridge Template Engine Components .............. SUCCESS [0.346s]
[INFO] Cambridge MVEL Expression Language Integration .... SUCCESS [0.345s]
[INFO] Cambridge JEXL Expression Language Integration .... SUCCESS [0.377s]
[INFO] Cambridge OGNL Expression Language Integration .... SUCCESS [0.345s]
[INFO] Cambridge Template JaxRS Integration .............. SUCCESS [0.340s]
[INFO] Cambridge Janino Expression Language Integration .. SUCCESS [0.370s]
[INFO] Cambridge Template Play Framework Integration ..... FAILURE [0.491s]
[INFO] Cambridge Template Spring Integration ............. SKIPPED
[INFO] Cambridge Template Struts Integration ............. SKIPPED
[INFO] Cambridge Simple Web Application .................. SKIPPED
[INFO] Benchmarking App .................................. SKIPPED
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 4.612s
[INFO] Finished at: Fri Jan 20 23:42:54 PST 2012
[INFO] Final Memory: 5M/81M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project cambridge-playframework: Could not resolve dependencies for project com.googlecode.cambridge:cambridge-playframework:jar:1.0: Could not find artifact com.playframework:playframework:jar:1.2.4 in central (http://repo1.maven.org/maven2) -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] 
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR]   mvn <goals> -rf :cambridge-playframework

Tom Carchrae

unread,
Jan 21, 2012, 6:25:09 AM1/21/12
to cambridge...@googlegroups.com
You can remove the play line from pom.xml and move along.  I don't think there is a Play maven repo - they share the hate. 

Erdinc - did the repo used to exist, or did you locally install Play with maven?  It's probably a good idea to remove it if so.  

erdincyilmazel

unread,
Jan 21, 2012, 8:38:38 AM1/21/12
to cambridge...@googlegroups.com, cambridge...@googlegroups.com
I always install the play framework jar manually into my local repo. There isn't a global repo for play as far as I know. Jon you can just comment out the play module reference from main project Pom file and try again.

Sent from my iPad
Reply all
Reply to author
Forward
0 new messages