title: Get file directory in Apache Velocity Template Language
body: <p>CLion uses Apache's Velocity Template Language (VTL) to create templates for C++ and C files.
  On CLion's help (<a href="https://www.jetbrains.com/help/clion/file-template-variables.html" rel="nofollow noreferrer">https://www.jetbrains.com/help/clion/file-template-variables.html</a>) a bunch of variables that can be used are listed.</p>
  
  <p>I was wondering however, if it would be possible to use the directory where a C++ file is created as a variable in one of my templates?
  I'm asking this because I like to structure my source files in a java/package-type fashion.</p>
  
  <p>All files in the "Utils" directory are part of the "Utils" namespace, all packages in the "Ui" Directory are part of the "Ui" namespace etc...</p>
  
  <p>So I was wondering if there's any way for me to obtain the parent directory of a file so I can use it in a template? (Maybe by setting a variable in my <code>CMakeLists.txt</code>?)</p>
  
  <p>Here's an example of what I'd like to achieve</p>
  
  <pre><code>#parse("C File Header.h")
  #[[#ifndef]]# ${INCLUDE_GUARD}
  #[[#define]]# ${INCLUDE_GUARD}
  
  ${NAMESPACES_OPEN}
  namespace ${CWD}
  
  class ${NAME}
  {
  
  };
  
  ${NAMESPACES_CLOSE}
  
  #[[#endif]]# //${INCLUDE_GUARD}
  </code></pre>
  
  <p>where <code>${CWD}</code> represents the folder the file is in.</p>
  
  <p>The <code>${NAMESPACE_OPEN}</code> and <code>${NAMESPACE_CLOSE}</code> directives seem to be purely symbolic for CLion, their websites lists it as "indicates the beginning/end of a namespace block created during refactoring."</p>