Why is "#include" stripped from output in a Velocity script?

Rob Knight's Avatar

Rob Knight

25 Feb, 2015 05:19 AM

I'm trying to use server-side includes to include a common file on multiple pages.

If I add `<!--#include virtual="../../path/to/file//file.html" -->` to my Velocity script,
Cascade 7.8.4 outputs it as `<!-- virtual="../../path/to/file//file.html" -->`

How do I get around this?

  1. 1 Posted by Rob Knight on 25 Feb, 2015 05:42 AM

    Rob Knight's Avatar

    OK, I found it. I needed to include a "\" in front of the `#include` because it is a file include directive in Velocity and Apache. The "\" tells Velocity to ignore it instead of processing it.

  2. 2 Posted by Ryan Griffith on 26 Feb, 2015 04:27 PM

    Ryan Griffith's Avatar

    Hi Rob,

    I am glad to hear you were able to resolve the issue with the #include. You could also use the following to avoid the Velocity directive confusion:

    <!--${_EscapeTool.h}include virtual="../../path/to/file//file.html" -->
    

    Where ${_EscapeTool.h} will output the hash sign for you during transformation.

    I'm going to go ahead and close this discussion, please feel free to comment or reply to re-open if you have any additional questions.

    Have a great day!

  3. Ryan Griffith closed this discussion on 26 Feb, 2015 04:27 PM.

Discussions are closed to public comments.
If you need help with Cascade CMS please start a new discussion.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac

 

26 Aug, 2016 01:19 PM
25 Aug, 2016 03:02 PM
25 Aug, 2016 12:50 PM
24 Aug, 2016 08:43 PM
24 Aug, 2016 07:20 PM
21 Aug, 2016 01:20 PM