Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FreeMarker Template load location missing #58

Open
edigitman opened this issue Apr 3, 2017 · 1 comment
Open

FreeMarker Template load location missing #58

edigitman opened this issue Apr 3, 2017 · 1 comment

Comments

@edigitman
Copy link

I have a POC with the following dependencies
com.sparkjava spark-core 2.5
com.sparkjava spark-template-freemarker 2.5.5

I took the example from this repo, the FreeMarkerEngine class. I have the simple Main class and a simple template with a placeholder for the message.

The issue is that in the Main class there is a comment saying that the template will be loaded from src/test/resources/spark/template/freemarker but this is not configured in the FreeMarkerEngine class at line 89 configuration.setClassForTemplateLoading(FreeMarkerEngine.class, "");

The second argument should be "spark\template\freemarker".

@Dobosz
Copy link

Dobosz commented Aug 4, 2017

This line is exactly like it supposed to be. This empty string is base package for getResource() of selected class loader. In this case FreeMarker will execute something like:
FreeMarkerEngine.class.getClassLoader().getResource (basePackage + ...)

If you are looking for path for template files see:
http://freemarker.org/docs/api/freemarker/template/Configuration.html#setDirectoryForTemplateLoading-java.io.File-

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants