#27 <include> and relative paths

closed-accepted
None
5
2002-10-12
2002-10-11
Anonymous
No

When a template called "/foo/bar/template.fm" has the
directive:

<include "header.fm">

the freemarker code will try to include the file
"/foo/header.fm" rather than "/foo/bar/header.fm". I
think this might be a mistake. This will fix it:

---
freemarker-2.1RC1/src/freemarker/template/Include.java
Sun Sep 29 06:33:28 2002
+++ freemarker/src/freemarker/template/Include.java Thu
Oct 10 17:37:09 2002@@ -86,7 +86,7 @@
{
super.setLocation(template, beginColumn,
beginLine, endColumn, endLine);
templatePath = template.getName();
- int lastSlash = templatePath.indexOf('/');
+ int lastSlash = templatePath.lastIndexOf('/');
templatePath = lastSlash == -1 ? "" :
templatePath.substring(0, lastSlash + 1);
}

Discussion

  • Logged In: YES
    user_id=546667

    Thank you! Fixed in the CVS. Will be released with FM 2.1 RC2.

     
    • assigned_to: nobody --> ddekany
    • status: open --> closed-accepted