Autogenerates views and templates for all the models in the project.
420041
def autogen(project_path):
    """"""
    generate_quickstart(project_path)

    project = StatikProject(project_path)
    project.config = StatikConfig(project.config_file_path)

    models = list(project.load_models().values())

    logger.info('Creating view and template for home page (index.html).')
    generate_yaml_file(os.path.join(project_path, StatikProject.VIEWS_DIR, 'index.yaml'),
                        {   
                            'path': '/',
                            'template': 'index'
                        }
    )
    generate_index_file(os.path.join(project_path, StatikProject.TEMPLATES_DIR, 'index.jinja2'))

    for model in models:
        logger.info('Creating view and template for model: %s' % model.name)
        generate_yaml_file(os.path.join(project_path, StatikProject.VIEWS_DIR, '%s.yaml' % model.name),
                            {   
                                'path': {
                                    'template': '/%s/{{ %s.pk }}' % (model.name, model.name),
                                    'for-each': {
                                        '%s' % model.name: 'session.query(%s).all()' % model.name
                                    }
                                },
                                'template': ('%s' % model.name),
                            }
        )
        generate_model_file(os.path.join(project_path, StatikProject.TEMPLATES_DIR, '%s.jinja2' % model.name),
                            project,
                            model,
                            model.fields.values())
999965
def get_templates(model):
    
    for template_name, template in templates.items():
        if issubclass(template.model, model):
            yield (template_name, template.layout._meta.verbose_name)
30355
protected function initTemplates()
    {
        foreach ($this->templates as $template => $templatePath) {
            $this->templates[$template] = $this->normalizePath($templatePath);
        }

        if (!isset($this->templates['default'])) {
            $this->templates['default'] = realpath(dirname(__DIR__) . '/../templates/default');
        }
    }
868666
def _project_auto_open(self):
        
        for project in self._projects.values():
            if project.auto_open:
                yield from project.open()
698384
protected function renderTemplates()
    {
        $finder = new Finder;

        $finder->files()->name('*'.self::TEMPLATE_FILENAME_EXTENSION)->in($this->targetPath);

        $twigRenderer = TwigRenderer::create(
            [
                'twig_extensions' => [ new ProjectExtension($this->configProvider) ],
                'twig_options' => [
                    'autoescape' => false,
                    'cache' => false,
                    'debug' => true,
                    'strict_variables' => true
                ],
                'template_paths' => [
                    $this->targetPath
                ]
            ]
        );

        foreach ($finder as $template) {
            $targetFilePath = $template->getPath().DIRECTORY_SEPARATOR.
                $template->getBasename(self::TEMPLATE_FILENAME_EXTENSION);

            if (!file_exists($targetFilePath) || (is_readable($targetFilePath) && $this->overwriteEnabled)) {
                $twigRenderer->renderToFile(
                    $template->getRelativePathname(),
                    $targetFilePath,
                    $this->data
                );
            }

            $msg = '[render] '.$template->getRelativePathname().' => '.$targetFilePath;

            if ($this->reportingEnabled) {
                $this->report[] = $msg;
            }
        }

        $this->fs->remove($finder);
    }
1255950
def generate_delete_view(self):
        """"""

        name = model_class_form(self.model + 'DeleteView')
        delete_args = dict(
            model=self.get_model_class,
            template_name=self.get_template('delete'),
            permissions=self.view_permission('delete'),
            permission_required=self.check_permission_required,
            login_required=self.check_login_required,
            success_url=reverse_lazy('{}-{}-list'.format(self.app, self.custom_postfix_url)),
            custom_postfix_url=self.custom_postfix_url
        )

        delete_class = type(name, (CrudBuilderMixin, DeleteView), delete_args)
        self.classes[name] = delete_class
        return delete_class
1079135
private function generateModel()
    {
        $modelInstance = Model::instance($this);
        $modelTemplateDir =
            dirname(dirname(__FILE__)).DS.'src'.DS.ucfirst('apps').DS.ucfirst('models').DS;

        $modelInstance->setModelTemplatePath($modelTemplateDir);
        $modelInstance->updateTemplate();
        $modelInstance->generate();

        return true;
    }
600007
function()
	{
		if(!this._modelBindersMap) this._initBinding();
		if(!this._collectionBinder)
		{
			this._explicitSubviewsStruct = null;

			if(this._template) this.element.innerHTML = this._template;

			if(this.render !== noop) this.render();
			this.renderSubviews();
		}
	}
453232
def init(self, project_name='', template='base', quiet=False, debug=False):
        ''''''

        self.logger.setLevel(DEBUG if debug else WARNING)

        self.logger.info('Project creation started.')

        self.logger.debug(f'Template: {template}')

        template_path = Path(template)

        if not template_path.exists():
            self.logger.debug(
                f'Template not found in {template_path}, looking in installed templates.'
            )

            installed_templates_path = Path(Path(__file__).parent / 'templates')

            installed_templates = [
                item.name for item in installed_templates_path.iterdir() if item.is_dir()
            ]

            self.logger.debug(f'Available templates: {installed_templates}')

            if template in installed_templates:
                self.logger.debug('Template found.')

            else:
                self.logger.debug('Template not found, asking for user input.')

                try:
                    template = prompt(
                        f'Please pick a template from {installed_templates}: ',
                        completer=WordCompleter(installed_templates),
                        validator=BuiltinTemplateValidator(installed_templates)
                    )

                except KeyboardInterrupt:
                    self.logger.warning('Project creation interrupted.')
                    return

            template_path = installed_templates_path / template

            self.logger.debug(f'Template path: {template_path}')

        if not project_name:
            self.logger.debug('Project name not specified, asking for user input.')

            try:
                project_name = prompt('Enter the project name: ')

            except KeyboardInterrupt:
                self.logger.warning('Project creation interrupted.')
                return

        project_slug = slugify(project_name)
        project_path = Path(project_slug)

        properties = {
            'title': project_name,
            'slug': project_slug
        }

        self.logger.debug(f'Project properties: {properties}')

        result = None

        with spinner('Generating project', self.logger, quiet, debug):
            copytree(template_path, project_path)

            text_types = '*.md', '*.yml', '*.txt', '*.py'

            text_file_paths = reduce(
                lambda acc, matches: acc + [*matches],
                (project_path.rglob(text_type) for text_type in text_types),
                []
            )

            for text_file_path in text_file_paths:
                self.logger.debug(f'Processing content of {text_file_path}')
                replace_placeholders(text_file_path, properties)

            for item in project_path.rglob('*'):
                self.logger.debug(f'Processing name of {item}')
                item.rename(Template(item.as_posix()).safe_substitute(properties))

            result = project_path

        if result:
            self.logger.info(f'Result: {result}')

            if not quiet:
                print('─' * 20)
                print(f'Project "{project_name}" created in {result}')
            else:
                print(result)

        else:
            self.logger.critical('Project creation failed.')
            exit(1)
1194363
void generate( Application application, Collection<TemplateEntry> templates ) {

		try {
			synchronized( this.generationLock ) {
				TemplateUtils.generate( application, this.outputDIR, templates, this.logger );
			}

		} catch( IOException e ) {
			this.logger.warning( "An error occurred while generating files from templates for application " + application );
			Utils.logException( this.logger, e );

		} catch( Throwable e ) {
			this.logger.warning( "An unexpected error occurred while generating files from templates for application " + application );
			Utils.logException( this.logger, new UndeclaredThrowableException( e ));
		}
	}
1368520
def load_views(self):
        """"""
        view_path = os.path.join(self.path, StatikProject.VIEWS_DIR)
        logger.debug("Loading views from: %s", view_path)
        if not os.path.isdir(view_path):
            raise MissingProjectFolderError(StatikProject.VIEWS_DIR)

        view_files = list_files(view_path, ['yml', 'yaml'])
        logger.debug("Found %d view(s) in project", len(view_files))
        views = {}
        for view_file in view_files:
            view_name = extract_filename(view_file)
            views[view_name] = StatikView(
                filename=os.path.join(view_path, view_file),
                encoding=self.config.encoding,
                name=view_name,
                models=self.models,
                template_engine=self.template_engine,
                error_context=self.error_context
            )

        return views
202640
protected function _initView ()
    {
        // Create default view model, to be used in all templates and layouts
        $this->appView  = new \Zend\View\Model\ViewModel();

        // Convenience access variables
        $this->_appView = $this->appView;
        $this->view     = $this->appView;
        $this->_view    = $this->appView;
    }
1003627
public function init()
    {
        // set name and id of view
        if (!$this->name) {
            if (!$this->id) {
                $this->id = $this->name = 'atk';
            } else {
                $this->name = $this->id;
            }
        } elseif (!$this->id) {
            $this->id = $this->name;
        }

        // initialize
        $this->_init();

        if (!$this->app) {
            $this->initDefaultApp();
        }

        if ($this->region && !$this->template && !$this->defaultTemplate && $this->owner && $this->owner->template) {
            $this->template = $this->owner->template->cloneRegion($this->region);

            $this->owner->template->del($this->region);
        } else {
            // set up template
            if (is_string($this->defaultTemplate) && is_null($this->template)) {
                $this->template = $this->app->loadTemplate($this->defaultTemplate);
            }

            if (!$this->region) {
                $this->region = 'Content';
            }
        }

        if ($this->template && !isset($this->template->app) && isset($this->app)) {
            $this->template->app = $this->app;
        }

        // add default objects
        foreach ($this->_add_later as list($object, $region)) {
            $this->add($object, $region);
        }

        $this->_add_later = [];
    }
955021
def ready(self):
        ''''''
        # set up the options
        self.options = {}
        self.options.update(DEFAULT_OPTIONS)
        for template_engine in settings.TEMPLATES:
            if template_engine.get('BACKEND', '').startswith('django_mako_plus'):
                self.options.update(template_engine.get('OPTIONS', {}))

        # dmp-enabled apps registry
        self.registration_lock = threading.RLock()
        self.registered_apps = {}

        # init the template engine
        self.engine = engines['django_mako_plus']

        # default imports on every compiled template
        self.template_imports = [
            'import django_mako_plus',
            'import django.utils.html',     # used in template.py
        ]
        self.template_imports.extend(self.options['DEFAULT_TEMPLATE_IMPORTS'])

        # initialize the list of providers
        ProviderRun.initialize_providers()

        # set up the parameter converters (can't import until apps are set up)
        from .converter.base import ParameterConverter
        ParameterConverter._sort_converters(app_ready=True)
1095722
function setupViewPartials() {
  
  // Set view path association object
  this.views.pathAsoc = {};

  // Partial & template regexes
  var self = this;
  var exts = this.templateExtensions;
  var partialRegex = new RegExp('\/views\/(.+)\/partials\/[a-zA-Z0-9-_]+\\.(' + exts.join('|') + ')$');
  var templateRegex = new RegExp('\\.(' + exts.join('|') + ')$');
  var layoutPath = this.mvcpath + 'views/' + this.paths.layout;

  var viewsPath = this.mvcpath + 'views';
  
  var partialPaths = [];
  
  if (fs.existsSync(viewsPath)) {
    
    fileModule.walkSync(viewsPath, function(dirPath, dirs, files) {
      
      for (var path,file,i=0; i < files.length; i++) {

        file = files[i];
        path = dirPath + "/" + file;

        if (partialRegex.test(path)) {

          // Only build valid partial views
          partialPaths.push(path);
          buildPartialView.call(self, path);
          watchPartial.call(self, path, buildPartialView);

        } else if (templateRegex.test(file)) {

          // Build partial views for everything inside app.paths.layout

          if (path.indexOf(layoutPath) === 0) {
            partialPaths.push(path);
            buildPartialView.call(self, path);
            watchPartial.call(self, path, buildPartialView);
          }

          // Only add valid templates to view associations
          self.views.pathAsoc[self.relPath(path.replace(self.regex.templateFile, ''))] = path;

        }
      }
    });
    
  }
  
  // Add Builtin Partials
  
  var Helper = protos.lib.helper;
  var builtinHelper = new Helper();
  
  for (var m in builtinHelper) {
    if (builtinHelper[m] instanceof Function) {
      this.registerViewHelper(m, builtinHelper[m], builtinHelper);
    }
  }
  
  // Helper Partials
  
  Object.keys(this.helpers).forEach(function(alias) {
    var m, method, hkey, helper = self.helpers[alias];
    for (m in helper) {
      if (helper[m] instanceof Function) {
        method = helper[m];
        hkey = (alias == 'main')
          ? util.format('%s', m)
          : util.format('%s_%s', alias, m);
        self.registerViewHelper(hkey, method, helper);
      }
    }
  });
  
  // Event when view partials are loaded

  this.emit('view_partials_loaded', this.views.partials);
  
  // Set shortcode context
  // NOTE: Automatically resets on hot code loading, so it's good.
  
  var shortcodeContext = this.__shortcodeContext = {};
  
  // Only add shortcode filter to context if enabled on config
  
  if (this.config.shortcodeFilter) {
    
    // Register shortcodes from partials
  
    var shortcode = self.shortcode;
    var partials = self.views.partials;
  
    Object.keys(this.views.partials).forEach(function(partial) {
      if (partial[0] === '$') {
        shortcodeContext[partial.replace(/^\$/, '#')] = self.views.partials[partial];
      } else {
        shortcodeContext[partial] = function(buf, params, locals) {
          if (buf) params.content = buf; // Provide wrapped content in params.content
          params.__proto__ = locals; // Set locals as prototype of params
          return partials[partial].call(null, params); // Provide params to partial, which is passed as locals
        }
      }
    });

    this.addFilter('context', function(buf, locals) {
      buf = this.shortcode.parse(buf, locals, shortcodeContext);
      return buf;
    });
    
  }
  
  // Event when view shortcodes are loaded

  this.emit('view_shortcodes_loaded', shortcodeContext);

}
754047
public function actionGenerateAll()
    {
        $foundTemplates = $this->findTemplatesFiles();

        if (!$foundTemplates) {
            $this->notifyNoTemplatesFound();
            return static::EXIT_CODE_NORMAL;
        }

        if (!$this->confirmGeneration($foundTemplates)) {
            return static::EXIT_CODE_NORMAL;
        }

        $templatePath = Yii::getAlias($this->templatePath);
        $fixtureDataPath = Yii::getAlias($this->fixtureDataPath);

        FileHelper::createDirectory($fixtureDataPath);

        $generatedTemplates = [];

        foreach ($foundTemplates as $templateName) {
            $this->generateFixtureFile($templateName, $templatePath, $fixtureDataPath);            
            $generatedTemplates[] = $templateName;
        }

        $this->notifyTemplatesGenerated($generatedTemplates);
    }
529506
function generateModels(mongoose) {
  internals.modelsGenerated = true

  let config = defaultConfig

  extend(true, config, module.exports.config)

  let Log = getLogger('models')

  module.exports.logger = Log

  return modelGenerator(mongoose, Log, config).then(function(models) {
    internals.globalModels = models
    return models
  })
}