Configure freemarker. All freemarker templates should be on the classpath in a package called
'freemarker'
356020
@Bean
  public FreeMarkerConfigurer freeMarkerConfigurer() {
    FreeMarkerConfigurer result =
        new FreeMarkerConfigurer() {
          @Override
          protected void postProcessConfiguration(Configuration config) {
            config.setObjectWrapper(new MolgenisFreemarkerObjectWrapper(VERSION_2_3_23));
          }

          @Override
          protected void postProcessTemplateLoaders(List<TemplateLoader> templateLoaders) {
            templateLoaders.add(new ClassTemplateLoader(FreeMarkerConfigurer.class, ""));
          }
        };
    result.setPreferFileSystemAccess(false);
    result.setTemplateLoaderPath("classpath:/templates/");
    result.setDefaultEncoding("UTF-8");
    Properties freemarkerSettings = new Properties();
    freemarkerSettings.setProperty(Configuration.LOCALIZED_LOOKUP_KEY, Boolean.FALSE.toString());
    freemarkerSettings.setProperty(Configuration.NUMBER_FORMAT_KEY, "computer");
    result.setFreemarkerSettings(freemarkerSettings);
    Map<String, Object> freemarkerVariables = Maps.newHashMap();
    freemarkerVariables.put("hasPermission", new HasPermissionDirective(permissionService));
    freemarkerVariables.put("notHasPermission", new NotHasPermissionDirective(permissionService));
    addFreemarkerVariables(freemarkerVariables);

    result.setFreemarkerVariables(freemarkerVariables);

    return result;
  }
72449
def create_install_template_skin(self):
        
        ckan_extension_template(self.name, self.target)
        self.install_package_develop('ckanext-' + self.name + 'theme')
1107007
protected void addClassPathes(final GroovyClassLoader classLoader) {
        if (classpath != null) {
            for (int i = 0; i < classpath.list().length; i++) {
                classLoader.addClasspath(classpath.list()[i]);
            }
        }
    }
951066
function loadTemplates() {
  const templatesPath = path.join(process.cwd(), plugin.config.templatesPath);

  return plugin.myrmex.fire('beforeTemplatesLoad')
  .then(() => {
    // Retrieve paths of all node packages
    return Promise.promisify(fs.readdir)(templatesPath);
  })
  .then(files => {
    // Load all packages configurations
    const templatePromises = [];
    _.forEach(files, (fileName) => {
      const templatePath = path.join(templatesPath, fileName);
      // subdir is the identifier of the template, so we pass it as the second argument
      templatePromises.push(loadTemplate(templatePath, fileName));
    });
    return Promise.all(templatePromises);
  })
  .then(templates => {
    // This event allows to inject code to add or delete or alter node templates configurations
    return plugin.myrmex.fire('afterTemplatesLoad', templates);
  })
  .spread(templates => {
    return Promise.resolve(templates);
  })
  .catch(e => {
    // In case the project does not have any template yet, an exception will be thrown
    // We silently ignore it
    if (e.code === 'ENOENT' && path.basename(e.path) === 'templates') {
      return Promise.resolve([]);
    }
    return Promise.reject(e);
  });
}
821078
def ckan_extension_template(name, target):
    
    setupdir = '{0}/ckanext-{1}theme'.format(target, name)
    extdir = setupdir + '/ckanext/{0}theme'.format(name)
    templatedir = extdir + '/templates/'
    staticdir = extdir + '/static/datacats'

    makedirs(templatedir + '/home/snippets')
    makedirs(staticdir)

    here = dirname(__file__)
    copyfile(here + '/images/chart.png', staticdir + '/chart.png')
    copyfile(here + '/images/datacats-footer.png',
        staticdir + '/datacats-footer.png')

    filecontents = [
        (setupdir + '/setup.py', SETUP_PY),
        (setupdir + '/.gitignore', DOT_GITIGNORE),
        (setupdir + '/ckanext/__init__.py', NAMESPACE_PACKAGE),
        (extdir + '/__init__.py', ''),
        (extdir + '/plugins.py', PLUGINS_PY),
        (templatedir + '/home/snippets/promoted.html', PROMOTED_SNIPPET),
        (templatedir + '/footer.html', FOOTER_HTML),
        ]

    for filename, content in filecontents:
        with open(filename, 'w') as f:
            f.write(content.replace('##name##', name))
102775
protected function _setupPaths()
    {
        $paths = Configure::read('App.paths.templates');

        $extraPaths = Configure::read('CrudView.templatePaths');
        if (!empty($extraPaths)) {
            $paths = array_merge($paths, (array)$extraPaths);
        }
        $paths[] = Plugin::classPath('CrudView') . 'Template' . DS;

        Configure::write('App.paths.templates', $paths);
    }
1167926
def set_templates_dir
        input = gets.chomp.strip
        root_path = input.sub(/\/\w*\/*$/, '')
        case
        when input.downcase == "b"
          jumpstart_menu
        when input.downcase == "x"
          exit_normal
        when File.directory?(input)
          puts "\n  A directory of that name already exists, would you like to set it as your template directory anyway? (Nothing will be copied or removed.)".yellow
          puts "  Yes (" + "y".yellow + ") or No (" + "n".yellow + ")?"
          set_templates_dir_to_existing_dir(input)
        when File.directory?(root_path)
          begin
            Dir.chdir(root_path)
            Dir.mkdir(input)
            files_and_dirs = FileUtils.sort_contained_files_and_dirs(JumpStart.templates_path)
            puts "\nCopying existing templates to #{input}"
            files_and_dirs[:dirs].each {|x| FileUtils.mkdir_p(FileUtils.join_paths(input, x))}
            files_and_dirs[:files].each {|x| FileUtils.cp(FileUtils.join_paths(JumpStart.templates_path, x), FileUtils.join_paths(input, x)) }
            JumpStart.templates_path = input.to_s
            JumpStart.dump_jumpstart_setup_yaml
            puts "\n  Transfer complete!".green
            puts "\n  The directory " + input.green + " has been set as the JumpStart templates directory."
            jumpstart_menu
          rescue
            puts "  It looks like you do not have the correct permissions to create a directory in #{root_path.red}"
          end
        else
          puts "  Couldn't find a directory of that name. Try again.".red
          set_templates_dir
        end
      end
1023415
public void includeUnescaped(String templatePath) throws IOException {
        URL resource = engine.resolveTemplate(templatePath);
        yieldUnescaped(ResourceGroovyMethods.getText(resource, engine.getCompilerConfiguration().getSourceEncoding()));
    }
1314537
function setupTemplates() {
  
  // Reset templates before proceeding
  // NOTE: This is needed for templates to be copatible with hot code loading
  this.templates = {};

  var self = this;
  var tplDir = app.mvcpath + app.paths.templates;
  var multiSlashes = this.regex.multipleSlashes;
  
  if (fs.existsSync(tplDir) && fs.statSync(tplDir).isDirectory()) {
    
    var files = protos.util.walkDir(tplDir, this.regex.templateFile);
  
    files.forEach(function(path) {
      buildTemplatePartial.call(this, path);
      watchPartial.call(this, path, buildTemplatePartial);
    }, this);
    
  }
  
  this.emit('templates_loaded', this.templates);
  
}
1218757
function template(files, staticPath) {
			return files ? files.map(function(filepath){
				paths = filepath.split(staticPath)[1].split('/')
				jsonpart = buildJsonPath(paths, filepath);
				return jsonpart;
			}) : ''
		}
993705
def templates_dir_options
        input = gets.chomp.strip.downcase
        case
        when input == "1"
          puts "  Please enter the absolute path for the directory that you would like to contain your jumpstart templates.".yellow
          puts "  e.g. /Users/your_name/projects/jumpstart_templates\n\n"
          set_templates_dir
        when input == "2"
          reset_templates_dir_to_default_check
        when input == "b"
          jumpstart_menu
        when input == "x"
          exit_normal
        else
          puts "  That command hasn't been understood. Try again!".red
          templates_dir_options
        end
      end
491529
def template(*args, **kwargs):
    '''
    
    '''
    tpl = args[0] if args else None
    template_adapter = kwargs.pop('template_adapter', SimpleTemplate)
    if tpl not in TEMPLATES or DEBUG:
        settings = kwargs.pop('template_settings', {})
        lookup = kwargs.pop('template_lookup', TEMPLATE_PATH)
        if isinstance(tpl, template_adapter):
            TEMPLATES[tpl] = tpl
            if settings: TEMPLATES[tpl].prepare(**settings)
        elif "\n" in tpl or "{" in tpl or "%" in tpl or '$' in tpl:
            TEMPLATES[tpl] = template_adapter(source=tpl, lookup=lookup, **settings)
        else:
            TEMPLATES[tpl] = template_adapter(name=tpl, lookup=lookup, **settings)
    if not TEMPLATES[tpl]:
        abort(500, 'Template (%s) not found' % tpl)
    for dictarg in args[1:]: kwargs.update(dictarg)
    return TEMPLATES[tpl].render(kwargs)
1014728
def build_template(self, template, template_file, package):
        

        try:
            from Cheetah.Compiler import Compiler
        except ImportError:
            self.announce("unable to import Cheetah.Compiler, build failed")
            raise
        else:
            comp = Compiler(file=template_file, moduleName=template)

        # load configuration if it exists
        conf_fn = DEFAULT_CONFIG
        if exists(conf_fn):
            with open(conf_fn, "rt") as config:
                comp.updateSettingsFromConfigFileObj(config)

        # and just why can't I configure these?
        comp.setShBang("")
        comp.addModuleHeader("pylint: disable=C,W,R,F")

        outfd = join(self.build_lib, *package.split("."))
        outfn = join(outfd, template + ".py")

        if not exists(outfd):
            makedirs(outfd)

        if newer(template_file, outfn):
            self.announce("compiling %s -> %s" % (template_file, outfd), 2)
            with open(outfn, "w") as output:
                output.write(str(comp))
732838
public void includeEscaped(String templatePath) throws IOException {
        URL resource = engine.resolveTemplate(templatePath);
        yield(ResourceGroovyMethods.getText(resource, engine.getCompilerConfiguration().getSourceEncoding()));
    }
607984
def _compose_cheetah_template_map(cache):
    

    from .cheetah import get_templates

    # pylint: disable=W0406
    # needed for introspection
    import javatools

    for template_type in get_templates():
        if "_" not in template_type.__name__:
            # we use the _ to denote package and class names. So any
            # template without a _ in the name isn't meant to be
            # matched to a change type.
            continue

        # get the package and change class names based off of the
        # template class name
        tn = template_type.__name__
        pn, cn = tn.split("_", 1)

        # get the package from javatools
        pk = getattr(javatools, pn, None)
        if pk is None:
            __import__("javatools." + pn)
            pk = getattr(javatools, pn, None)

        # get the class from the package
        cc = getattr(pk, cn, None)
        if cc is None:
            raise Exception("no change class for template %s" % tn)

        # associate a Change class with a Template class
        cache[cc] = template_type

    return cache
153658
def load_default_templates(self):
        """"""
        for importer, modname, is_pkg in pkgutil.iter_modules(templates.__path__):
            self.register_template('.'.join((templates.__name__, modname)))
107190
protected function installTemplates()
    {
        $path = $this->getCodeDir() . '/client/templates';
        if (file_exists($path))
        {
            $ts = Eresus_Template_Service::getInstance();
            $it = new DirectoryIterator($path);
            foreach ($it as $fileInfo)
            {
                /** @var DirectoryIterator $fileInfo */
                if (!$fileInfo->isDot())
                {
                    $ts->install($fileInfo->getPathname(), $this->getName());
                }
            }
        }
    }