This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 98011 - [freemarker] <#include> not working
Summary: [freemarker] <#include> not working
Status: RESOLVED FIXED
Alias: None
Product: platform
Classification: Unclassified
Component: Data Systems (show other bugs)
Version: 6.x
Hardware: All All
: P2 blocker (vote)
Assignee: Jaroslav Tulach
URL:
Keywords:
Depends on:
Blocks: 95399
  Show dependency tree
 
Reported: 2007-03-15 17:04 UTC by Jan Pokorsky
Modified: 2008-12-22 10:54 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
SCFTHandlerTest.testCreateFromTemplateUsingFreemarkerAndInclude (2.40 KB, text/plain)
2007-03-15 17:09 UTC, Jan Pokorsky
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Jan Pokorsky 2007-03-15 17:04:19 UTC
It looks like it is not possible to reference files using relative or absolute
path in <#include filename>. The <#include> works just in case the referenced
file is in the same folder as the template.

See attached test SCFTHandlerTest.testCreateFromTemplateUsingFreemarkerAndInclude.

Neither <#include "../includes/include.txt"> nor <#include
"/includes/include.txt"> works.
Comment 1 Jan Pokorsky 2007-03-15 17:09:21 UTC
Created attachment 39547 [details]
SCFTHandlerTest.testCreateFromTemplateUsingFreemarkerAndInclude
Comment 2 Jaroslav Tulach 2007-03-16 07:35:57 UTC
I see. I'll try to see freemarker docs of what needs to be done.
Comment 3 Jaroslav Tulach 2007-03-16 07:45:10 UTC
Freemarker seems to support something called "acquisition" include, see:
http://freemarker.sourceforge.net/docs/ref_directive_include.html
I'll (next week) or you can (today) modify the test to use 

<#include "*/includes/include.txt">

and see if that will work. Imho, it should. If not (possibly there can be 
problem with root of templates), I'll investigate and fix next week.
Comment 4 Jan Pokorsky 2007-03-16 20:59:00 UTC
<#include "*/includes/include.txt">
does not help. It is for cases you would place the file to some parent folder.
You will have to configure the freemarker. See
http://freemarker.sourceforge.net/docs/pgui_quickstart_createconfiguration.html
Comment 5 Jaroslav Tulach 2007-03-19 16:36:08 UTC
Try it now. Imho both */path as well as ../path will work now. See the changes 
in the test for example:


Checking in test/unit/src/org/netbeans/api/templates/ProcessorTest.java;
/shared/data/ccvs/repository/libs/freemarker/test/unit/src/org/netbeans/api/templates/ProcessorTest.java,v  
<--  ProcessorTest.java
new revision: 1.3; previous revision: 1.2
done
Checking in src/org/netbeans/libs/freemarker/FreemarkerEngine.java;
/shared/data/ccvs/repository/libs/freemarker/src/org/netbeans/libs/freemarker/FreemarkerEngine.java,v  
<--  FreemarkerEngine.java
new revision: 1.3; previous revision: 1.2
done
Checking in src/org/netbeans/libs/freemarker/RsrcLoader.java;
/shared/data/ccvs/repository/libs/freemarker/src/org/netbeans/libs/freemarker/RsrcLoader.java,v  
<--  RsrcLoader.java
new revision: 1.3; previous revision: 1.2
done
Checking in nbproject/project.properties;
/shared/data/ccvs/repository/libs/freemarker/nbproject/project.properties,v  
<--  project.properties
new revision: 1.3; previous revision: 1.2
done
Checking in manifest.mf;
/shared/data/ccvs/repository/libs/freemarker/manifest.mf,v  <--  manifest.mf
new revision: 1.3; previous revision: 1.2
Comment 6 Jan Pokorsky 2007-03-19 20:46:41 UTC
In order to make this working even in IDE I changed order of attribute
evaluation. FREEMARKER_TEMPLATE is preferred to ScriptEngine.FILENAME now.

Unfortunately javadoc of ScriptEngine.FILENAME is a bit loosely defined so it is
unclear if it should contain also the path. More appropriate attribute for the
executed resource would be ScriptEngine.URL IMO but it is another story.

/cvs/libs/freemarker/src/org/netbeans/libs/freemarker/FreemarkerEngine.java,v 
<--  FreemarkerEngine.java
new revision: 1.4; previous revision: 1.3