include template not found

15 views
Skip to first unread message

wat3r...@gmail.com

unread,
Nov 12, 2015, 1:50:13 PM11/12/15
to rythmengine
All,

I have a Spring MVC web application and trying to use rythm to generate messages using a set of templates (txt files). I have a main template that includes other templates in a separate directory. I have the following structure:

WEB-INF
|------- resources
          |------- templates
                    |------- section
                              |------- help.txt
                              message.txt

Basically, message.txt has a line @include ("section.help"). However, this does not work. I get an "include template not found". I tried to include "resources.templates.section.help" -- which didn't work either. What is the correct way to include another template?

Thanks,
Maria

green

unread,
Nov 12, 2015, 4:26:18 PM11/12/15
to rythmengine
Are you using https://github.com/greenlaw110/spring-rythm? How do you configure your spring mvc configuration file in terms of Rythm? 

BTW, you can use @section.help() which is more elegant in comparing to @include("section.help")

--
You received this message because you are subscribed to the Google Groups "rythmengine" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rythmengine...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

wat3r...@gmail.com

unread,
Nov 13, 2015, 3:19:09 PM11/13/15
to rythmengine
I'm not using spring-rythm. I'm not using rythm to generate web pages or views. What I'm generating are text files. Do I really need spring-rythm for this? Is there any way to specify or configure the rythm engine so it knows where to find the files? Or, does the engine look at specific paths?

I also tried @section.help(). That also did not work. Actually, I changed it to @sec.help() first because section is a keyword. However, when I processed the rythm file, it gave me an error indicating that sec is not a known variable.

Maria

green

unread,
Nov 13, 2015, 3:45:44 PM11/13/15
to rythm...@googlegroups.com
If you are using purely RythmEngine, what did you set for the "home.template.dir" configuration?

wat3r...@gmail.com

unread,
Nov 16, 2015, 2:07:25 PM11/16/15
to rythmengine
Thanks! Sorry, I'm a complete newbie to Rythm and didn't realize there is a home.template.dir property. This put me in the right direction.

Although, I had thought that if the template file ends with a .txt that sub-templates will also be assumed as .txt files. The engine could not find the file with .txt. However, when I changed them to .html, then the engine was able to find them. Is there any way to specify that the file extension to search for is txt? Is there documentation of all of the properties that can be configured?

Thanks again,
Maria

green

unread,
Nov 16, 2015, 3:04:49 PM11/16/15
to rythmengine
How did you specify your template in Java program?

If you go engine.render("/path/to/template.txt", args); it shall be able to find the template file with .txt suffix. However if you say engine.render("/path/to/template", args); it will by default looking for template end with ".html"

wat3r...@gmail.com

unread,
Nov 16, 2015, 3:10:13 PM11/16/15
to rythmengine
I'm using engine.render(file, args).

Here's a snippet of what I have

Resource  resource = context.getResource("classpath:./resources/templates/filename.txt");
File f = resource.getFile();
engine.render(f, args);

green

unread,
Nov 16, 2015, 3:14:54 PM11/16/15
to rythm...@googlegroups.com
You lost the ".txt" context when you load file directly.

try this:
engine.render("filename.txt");

given that you have set the template home to "resources/templates" already

wat3r...@gmail.com

unread,
Nov 16, 2015, 3:24:19 PM11/16/15
to rythmengine
Ahh that make sense. It works! Thanks so much for the help!

Maria
Reply all
Reply to author
Forward
0 new messages