@function loadTemplates

@param {array|string} dirs

@returns {Promise}
481992
function loadTemplates (dirs, options) {
    // require dirs to be array
    if (!Array.isArray(dirs)) {
        dirs = [dirs]
    }
    // templates indexed by absolute file name
    var templates = {}
    // load all templates in all directories
    return Promise.each(dirs, dir => {
        // load all files under dir
        return globby('**/*'+GLOBAL.ext, {
            cwd: dir,
            follow: true,
        })
        // compile templates for files
        .then(files => {
            return loadTemplatesFiles(dir, files, options, templates)
        })
    })
    // resolve with templates
    .then(() => templates)
}
835466
function readDirsParallel(dirs, cb) {
  var funcs = [];
  dirs.forEach(function(dir) {
    funcs.push(readDirAbs.bind(null, dir));
  });
  async.parallel(funcs, function(err, results) {
    if (err) {
      return cb(err, null);
    }
    // Flatten results and return
    var flat = [].concat.apply([], results);
    cb(null, flat);
  }
  );
}
1340512
async function getTemplate(templatesList, templateName = null) {
  if (!templateName) {
    const templatesArray = Object.entries(templatesList).map(([name, value]) => ({ name, value }))
    const { template } = await inquirer.prompt(templateQuestions.template(templatesArray))
    return template
  }
  if (templateName in templatesList) {
    return templatesList[templateName]
  }
  throw Error(`The template '${templateName}' does't exists`)
}
833059
public void loadRefasterJsTemplate(String refasterjsTemplate) throws IOException  {
    checkState(
        templateJs == null, "Can't load RefasterJs template since a template is already loaded.");
    this.templateJs =
        Thread.currentThread().getContextClassLoader().getResource(refasterjsTemplate) != null
            ? Resources.toString(Resources.getResource(refasterjsTemplate), UTF_8)
            : Files.asCharSource(new File(refasterjsTemplate), UTF_8).read();
  }
1218757
function template(files, staticPath) {
			return files ? files.map(function(filepath){
				paths = filepath.split(staticPath)[1].split('/')
				jsonpart = buildJsonPath(paths, filepath);
				return jsonpart;
			}) : ''
		}
20314
function renderTemplate(contents, data, filename) {
    if (!templateCache.hasOwnProperty(contents)) {
      var jadeOptions = merge.recursive({}, options.jadeOptions, {filename: filename});
      templateCache[contents] = options.jade.compile(contents, jadeOptions);
    }
    var locals = merge.recursive({}, data, {locals: locals});
    return templateCache[contents](data);
  }
489257
function FileSystemLoader(dir, options) {
    this.dir = dir.replace(/\/$/, '');
    this.options = options || (options = {});
    this.posts = [];
    this.files = {};
    this.ignore = {};
    var self = this;
    (options.ignore || FileSystemLoader.ignore).forEach(function (file) {
        self.ignore[file] = true;
    });
    process.nextTick(function () {
        self.loadPosts();
    });
}
1101955
function loadFormatters(){
    var arrFiles = glob.sync('./formatters/*.js', {
        'cwd': __dirname,
        'dot': false,
        'nodir': true,
        'strict': false,
        'silent': true
    });
    var mapFormatters = {};
    arrFiles.forEach(function(file){
        var fileInfo = path.parse(file);
        var formatterPath = path.resolve(__dirname, file);
        mapFormatters[fileInfo.name] = require(formatterPath);
    });
    return mapFormatters;
}
490893
function loadLayouts (options) {
    // return cached layouts if caching enabled
    if (options.cache && GLOBAL.layouts) {
        return GLOBAL.layouts
    }
    // load layouts
    GLOBAL.layouts = loadTemplates(GLOBAL.layoutDirs, options)
    // return promise that will be resolved with layouts
    return GLOBAL.layouts
}
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);
  
}
303124
function installTemplates( $templateList, $package, $subdirectory, &$installParameters )
    {
        if ( !$templateList )
        {
            return true;
        }
        $siteAccessDesignPathArray = array();
        $templateRootPath = $package->path() . '/' . $subdirectory;
        foreach( $templateList->getElementsByTagName( 'file' ) as $fileNode )
        {
            $originalSiteAccess = $fileNode->getAttribute( 'site-access' );
            if ( isset( $installParameters['site_access_map'][$originalSiteAccess] ) )
            {
                $newSiteAccess = $installParameters['site_access_map'][$originalSiteAccess];
            }
            else
            {
                $newSiteAccess = $installParameters['site_access_map']['*'];
            }

            if ( !isset( $siteAccessDesignPathArray[$newSiteAccess] ) )
            {
                $ini = eZINI::instance( 'site.ini', 'settings', null, null, true );
                $ini->prependOverrideDir( "siteaccess/$newSiteAccess", false, 'siteaccess' );
                $ini->loadCache();

                if ( isset( $installParameters['design_map'] ) )
                {
                    $designMap = $installParameters['design_map'];
                    if ( isset( $designMap[$originalSiteAccess] ) )
                        $siteAccessDesignPathArray[$newSiteAccess] = eZTemplateDesignResource::designStartPath() . '/' . $designMap[$originalSiteAccess];
                    else
                        $siteAccessDesignPathArray[$newSiteAccess] = eZTemplateDesignResource::designStartPath() . '/' . $designMap['*'];
                }
                else
                {
                    $siteAccessDesignPathArray[$newSiteAccess] = eZTemplateDesignResource::designStartPath() . '/' . $ini->variable( "DesignSettings", "StandardDesign" );
                }
            }

            $path = '';
            foreach( $fileNode->childNodes as $pathNode )
            {
                if ( $pathNode->nodeName == 'path' )
                {
                    $path = $pathNode->nodeValue;
                    break;
                }
            }

            $sourcePath = $templateRootPath . $path;
            $destinationPath = $siteAccessDesignPathArray[$newSiteAccess] . $path;

            eZDir::mkdir( eZDir::dirpath( $destinationPath ), false, true );
            if ( !eZFileHandler::copy( $sourcePath, $destinationPath ) )
                return false;

//             eZDebug::writeNotice( 'Copied: "' . $sourcePath . '" to: "' . $destinationPath . '"', __METHOD__ );
        }
        return true;
    }
1152887
function runTemplates(){
  getTemplatesList().then(function(knownTemplates){
    knownTemplates.forEach(function(el){
      console.log(el.id.info + ' : ' +el.desc);
    });
  });
}
428573
function loadTemplates(appName) {

    let appConfig = AmorphicContext.applicationConfig[appName] || {};
    let applicationSource = AmorphicContext.applicationSource;
    let applicationSourceMap = AmorphicContext.applicationSourceMap;
    let controllerPath = (appConfig.appConfig.controller || 'controller.js');
    let matches = controllerPath.match(/(.*?)([0-9A-Za-z_]*)\.js$/);
    let prop = matches[2];
    let baseTemplate = buildBaseTemplate(appConfig);

    applicationSource[appName] = '';
    applicationSourceMap[appName] = '';

    // Inject into it any db or persist attributes needed for application
    if (appConfig.initObjectTemplate && typeof appConfig.initObjectTemplate === 'function') {
        appConfig.initObjectTemplate(baseTemplate);
    }

    return [
        baseTemplate,
        getTemplates(baseTemplate, appConfig.appPath, [prop + '.js'], appConfig, appName)
    ];
}
1192848
function loadResources (styleArray) {
  const publicPath = '/public';
  var results = {};
  for (let source of styleArray) {
    if (source.resources) {
      for (let category in source.resources) {
        if (source.resources.hasOwnProperty(category)) {
          if (!results.hasOwnProperty(category)) {
            results[category] = {};
          }
          for (let item in source.resources[category]) {
            results[category][item] = source.resources[category][item];
            results[category][item].dataPromise = new Promise(resolve => {
              getJSON(publicPath + results[category][item].src)
                .then(data => {
                  resolve(data);
                });
            });
          }
        }
      }
    }
  }
  return results;
}
1078817
function readDirSync (dir, allFiles = []) {
  const files = fs.readdirSync(dir).map(f => join(dir, f))
  allFiles.push(...files)
  files.forEach(f => {
    fs.statSync(f).isDirectory() && readDirSync(f, allFiles)
  })
  return allFiles
}
580400
private function findTemplatesInDirectory($dir, $namespace = null, array $excludeDirs = [])
    {
        if (!is_dir($dir)) {
            return [];
        }

        $templates = [];
        foreach (Finder::create()->files()->followLinks()->in($dir)->exclude($excludeDirs) as $file) {
            $templates[] = (null !== $namespace ? '@'.$namespace.'/' : '').str_replace('\\', '/', $file->getRelativePathname());
        }

        return $templates;
    }
314493
function (done) {
        glob(path.join(__dirname, "*.ejs"), function (err, files) {
            if (err) {
                return done(err);
            }

            var templates = {};

            async.forEach(files, function (file, done) {
                fs.readFile(file, "utf8", function (err, data) {
                    if (err) {
                        return done(err);
                    } else {
                        templates[path.basename(file, ".ejs")] = _.template(data);
                        done();
                    }
                });
            }, function (err) {
                if (err) {
                    return done(err);
                }

                done(null, templates);
            });
        });
    }