Loads templates for an app at start up time.

@param {String} appName - The app name.

@returns {[Object, Object]} unknown
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)
    ];
}
484698
function findView(app, name) {
    var keys = app.viewTypes.renderable;
    var len = keys.length;
    var i = -1;

    var res = null;
    while (++i < len) {
      res = app.find(name, keys[i]);
      if (res) {
        break;
      }
    }
    return res;
  }
927707
function(dirpath) {
    try {

      // Make the directory under the app
      if (dirpath !== '/') {
        FS.mkdirSync(Path.join('.', appPath, dirpath));
      }

      // Read the template directory
      var templateDir = Path.join(__dirname, '../template/app', dirpath);
      var files = FS.readdirSync(templateDir);
      files.forEach(function(file) {
        var fullFile = Path.join(templateDir, file);
        var stat = FS.statSync(fullFile);
        if (stat.isDirectory()) {
          // Go into it
          outputDir(Path.join(dirpath, file));
        }
        else {
          outputFile(dirpath, file);
        }
      });

    } catch(e) {
      logger.fatal('Template', 'Cannot process template directory: ' + dirpath + '. reason: ', e.toString());
      process.exit(1);
    }
  }
1132894
function createApp (appname, spec, cb, resourceModules) {
  var moduleNames = resourceModules
  async.parallel([ function (cb) {
    async.each(spec.agents, function (agent, cb) {
      moduleNames.push(agent.name)
      createAgent(appname, spec, agent, cb)
    }, cb)
  }, function (cb) {
    async.each(spec.crud, function (crud, cb) {
      var crudName = crud.name
      if (crudName.charAt(0) == '/') {
        crudName = crudName.substr(1)
      }
      crud.name = crudName.replace(/\//g, '_')
      moduleNames.push(crud.name)
      createCrud(appname, spec, crud, cb)
    }, cb)
  }, function (cb) {
    createTemplate(appname, 'app.js', {
      moduleNames: moduleNames,
      agents: spec.agents
    })
    cb()
  }, function (cb) {
    createTemplate(appname, 'appConfig.js', {
      moduleNames: moduleNames,
      agents: spec.agents
    })
    cb()
  } ], function (err) {
    fs.mkdir(path.join(path.resolve(appname), 'generated', 'locale'), function (response) {
      createLocale(appname)
      cb()
    })
  })
}
566518
function createTemplate (appname, filename, data) {
  var content, ext;
  if (data) {
    data.appname = appname
  }
  if(ignoreFileTypes.test(filename)){
    console.log('Don\'t FUTZ binary files', filename);
    content = getUnrenderedTemplateContents(filename);
  } else  {
    content = getTemplateContents(filename, data)
    // ext = path.extname(filename)
  }
    fs.writeFileSync(path.join(appname, filename), content)
  
}
293258
function loadInfo() {
    try {
      var data = fs.readFileSync(__rootdir + '/package.json', { encoding: 'utf8' });
      var tmp = JSON.parse(data);
      appPackage = {
        name: tmp.name || null,
        version: tmp.version || 1
      }
    } catch(e) {
      return; // nothing to do.
    }
  }
1265261
function(file){
        const list = require(utils.getAppLocalPath() + file);
        if(!isObject(list)) return false;

        Object.keys(list).forEach(key => {
            let window = list[key];
            this.createNew(key, window.title, window.url, window.setupTemplate, window.setup);
        });
    }
95537
function launchApp(appName, appState, start, debug) {

	if (Array.isArray(start)) {

		// obtain appState
		if (!appState) {
			appState = {
				app: appName,
				created: Date.now(),
				crashCount: 0,
				killMap: {}
			}
		} else for (var aPid in appState.killMap) appState.killMap[aPid]()

		// launch the app
		var args = start.slice() // clone the array
		var command = args.shift() // extract command
		var child = child_process.spawn(command, args, options)
			.on('exit', childExit)
		streamlabeller.logChild(child, appName, write)
		var pid = appState.pid = child.pid
		appState.killMap[pid] = killChild
		var didKill
		var pendingKill
		var killTimer

		// update ui
		appState.lastLaunch = Date.now()
		appState.state = debug ? 'debug' : 'run'
		sendToUi({app: appName, pid: appState.pid, state: appState.state, lastLaunch: appState.lastLaunch})

	} else sendToUi({error: 'Bad launch command', isConfig: true, message: {app: appName}})

	return appState

	function killChild() {
		delete appState.killMap[pid]

		var t
		if (!didKill) {
			didKill = true
			pendingKill = true

			// update ui
			if (appState.pid == pid) {
				appState.state = 'stopping'
				sendToUi({app: appName, state: appState.state})
			}

			// attempt graceful kill (ctrl-Break)
			t = Date.now()
			killTimer = setTimeout(sigResult, graceKillPeriod)
			process.kill(pid, 'SIGINT')
		}

		function sigResult() {
			killTimer = null
			if (pendingKill) { // the process did not die
				//console.log(processName, proc.app, 'Force kill at: ' + (Date.now() - t) / 1e3)
				// now the evil sigterm
				process.kill(pid)
			}
		}
	}

	function childExit(code) {
		delete appState.killMap[pid]
		child.removeListener('exit', childExit)
		pendingKill = false
		if (killTimer) {
			clearTimeout(killTimer)
			killTimer = null
		}
		if (!didKill) appState.crashCount++
		if (appState.pid == pid) {
			appState.pid = 0
			appState.exitCode = code
			appState.lastExit = Date.now()
			appState.state = didKill ? 'stop' : 'crash'
			if (!didKill) appState.lastCrash = appState.lastExit
			sendToUi({app: appName, exit: appState.exitCode, state: appState.state, lastExit: appState.lastExit})
		}
		child = null
	}

}
647135
def app_templates_dirs(self):
        
        app_templates_dirs = OrderedDict()
        for app_config in apps.get_app_configs():
            templates_dir = os.path.join(
                getattr(app_config, 'path', '/'), 'templates')
            if os.path.isdir(templates_dir):
                templates_dir = upath(templates_dir)
                app_templates_dirs[app_config.name] = templates_dir
                app_templates_dirs[app_config.label] = templates_dir
        return app_templates_dirs
642285
function(appName) {

    // Validate inputs.
    return Promise.try(function() {
      if (appName && typeof appName !== 'string') {
        throw new TypeError('Invalid appName: ' + appName);
      }

      if (typeof appName === 'string') {
        appName = appName.replace(/-/g, '');
      }
    })

    .then(function() {
      return Promise.retry(function() {
        return docker.list(appName);
      });
    });

  }
819012
function loadListByName(listName, args, skipCache = false) {
    checkIsString('listName', listName);
    const configurationElement = getElement(listName);
    if (typeof configurationElement !== 'function') {
        throw new Error(`You are trying to load the reference list: ${listName} which does not have a list configure.`);
    }
    let now = _getTimeStamp();
    if (cache[listName] && (now - cache[listName].timeStamp) < getCacheDuration() && !skipCache) {
        _deletePromiseWaiting(listName);
        //console.info('data served from cache', listName, cache[listName].value);
        return Promise.resolve(cache[listName].value);
    }
    //Call the service, the service must return a promise.
    return configurationElement(args)
        .then((data) => {
            return _cacheData(listName, data)
        });
}
232947
def create_view_for_template(app_name, template_name):
    '''
    
    '''
    # ensure the template exists
    apps.get_app_config('django_mako_plus').engine.get_template_loader(app_name).get_template(template_name)
    # create the view function
    def template_view(request, *args, **kwargs):
        # not caching the template object (getting it each time) because Mako has its own cache
        dmp = apps.get_app_config('django_mako_plus')
        template = dmp.engine.get_template_loader(app_name).get_template(template_name)
        return template.render_to_response(request=request, context=kwargs)
    template_view.view_type = 'template'
    return template_view
684148
function App() {
    require('colors');

    /**
     * All of the developer defined middlewares.
     *
     * @var {Array}
     * @protected
     */
    this.__middlewares = [];

    /**
     * The filter instance
     * @var {Object}
     */
    this.filter;

    /**
     * The list of loaded service providers.
     *
     * @var {Object}
     * @protected
     */
    this.__loadedProviders = {};

    /**
     * Indicates if the application has "booted".
     *
     * @var {Boolean}
     * @protected
     */
    this.__booted = false;

    /**
     * The array of booting callbacks.
     *
     * @var {Array}
     * @protected
     */
    this.__bootingCallbacks = [];

    /**
     * The array of booted callbacks.
     *
     * @var {Array}
     * @protected
     */
    this.__bootedCallbacks = [];

    /**
     * Node HTTP server reference.
     *
     * @var {Object}
     * @protected
     */
    this.__server;

    /**
     * The application locals object.
     *
     * @var {Object}
     */
    this.locals = {};

    /**
     * Aliases for internal Positron module
     *
     * @type {Object}
     * @protected
     */
    this.__aliases = {};

    var self = this;

    /**
     * Run the application and send the response.
     *
     * @param  request
     * @param  response
     * @return {void}
     */
    this.run = function (request, response) {
        var reqDomain = domain.create();

        reqDomain
            .on('error', self.handleError.bind(self, request, response))
            .run(function () {
                self.__getStackedClient().handle(request, response);
            });
    };

}
585705
function loadTemplatesFiles (dir, files, options, templates) {
    // require files
    if (!Array.isArray(files)) {
        return Promise.resolve()
    }
    // load template for each file
    return Promise.each(files, file => {
        // get absolute file from dir
        var absFile = dir+'/'+file
        // get express template name by stripping off extension
        file = file.replace(GLOBAL.extRegExp, '')
        // if template has already been defined then do not replace so that
        // first incidence of file in multiple paths is used
        if (templates[file]) {
            return
        }
        // load template
        var promise = templates[file] = loadTemplate(absFile, options)
        // once template is loaded replace promise with template
        .then(template => {
            templates[file] = template
        })
        // wait for template to load
        return promise
    })
}
597107
public Application getRegisteredApplications(String appName) {
        return appNameApplicationMap.get(appName.toUpperCase(Locale.ROOT));
    }
127669
function list(appName, callback) {
    if (!appName) {
      return callback(ArgumentError('appName'));
    }

    var uri = format('/%s/apps/%s/config/', deis.version, appName);
    commons.get(uri, function onListResponse(err, result) {
      console.log(result);
      callback(err, result ? extractLimits(result) : null);
    });
  }
1269101
def app_view(name, **kwargs):
    
    ctx = Context(**kwargs)
    ctx.execute_action('app:view', **{
        'storage': ctx.repo.create_secure_service('storage'),
        'name': name,
    })