Get the scaffolded template for a view

@param  string $name
@return string Compiled template
351281
protected function getScaffoldedTemplate($name)
    {
        $model = $this->cache->getModelName();  // post
        $models = Pluralizer::plural($model);   // posts
        $Models = ucwords($models);             // Posts
        $Model = Pluralizer::singular($Models); // Post

        // Create and Edit views require form elements
        if ($name === 'create.blade' or $name === 'edit.blade')
        {
            $formElements = $this->makeFormElements();

            $this->template = str_replace('{{formElements}}', $formElements, $this->template);
        }

        // Replace template vars in view
        foreach(array('model', 'models', 'Models', 'Model') as $var)
        {
            $this->template = str_replace('{{'.$var.'}}', $$var, $this->template);
        }

        // And finally create the table rows
        list($headings, $fields, $editAndDeleteLinks) = $this->makeTableRows($model);
        $this->template = str_replace('{{headings}}', implode(PHP_EOL."\t\t\t\t", $headings), $this->template);
        $this->template = str_replace('{{fields}}', implode(PHP_EOL."\t\t\t\t\t", $fields) . PHP_EOL . $editAndDeleteLinks, $this->template);

        return $this->template;
    }
1030870
public function getFile($name)
    {
        if ($file = $this->resolveFile($name)) {
            return $file;
        } else {
            $components = $this->parseResource($name);
            throw new \RuntimeException(sprintf('Template "%s" not found in directories "%s"', $components['file'], implode('", "', $components['dirs'])));
        }
    }
871500
public function make(string $name): Template
    {
        $name = \trim($name, '/\\');
        $file = $this->compile($name);

        return new Template($this, $name, $file);
    }
145421
public function getMenu(string $name, ViewInterface $view = null)
    {
        $menu = $this->menuFactory->getMenu($name);

        return $this->environment->render($menu->get('template'), [
            'menu' => $menu,
            'admin' => $view,
        ]);
    }
1350285
public function getSource($name)
    {
        /** @var TemplateDocument $doc */
        $doc = $this->getDocument($name);
        if (is_null($doc) || !($doc instanceof TemplateDocument))
        {
            throw new Twig_Error_Loader(sprintf('Template "%s" does not exist.', $name));
        }
        $content = $doc->getContent();
        return $content;
    }
1034882
public function find($name)
    {
        if (isset($this->views[$name])) {
            return $this->views[$name];
        }

        if ($this->hasHintInformation($name = trim($name))) {
            return $this->views[$name] = $this->findNamedPathView($name);
        }

        return $this->views[$name] = $this->findInPaths($name, $this->paths);
    }
169114
public function getPossibleViewFiles($name)
    {
        $parts = explode(self::FALLBACK_PARTS_DELIMITER, $name);
        $templates[] = array_shift($parts);
        foreach ($parts as $i => $part) {
            $templates[] = $templates[$i].self::FALLBACK_PARTS_DELIMITER.$part;
        }
        rsort($templates);
        return $this->getPossibleViewFilesFromTemplates($templates);
    }
589918
public static function loadCoreView(string $name) {
      $base = __DIR__ . '/../../Views/';
      if (!file_exists($base . $name . '.view')) {
        throw new \Nuki\Exceptions\Base('The view file "' . $name . '" does not exist.');
      }
      
      return file_get_contents($base . $name . '.view');
    }
259760
protected function findTemplate($name)
    {
        if (!$this->isLoadableTemplate($name)) {
            throw new \Twig_Error_Loader(sprintf('Malformed namespaced template name "%s" (expecting "%stemplate_name").', $name, $this->prefix));
        }

        $templateIdentifier = substr($name, strlen($this->prefix));
        $template = $this->repository->find($templateIdentifier);
        if ($template === null) {
            throw new \Twig_Error_Loader(sprintf('Unable to find template "%s".', $name));
        }
        if (!($template instanceof TemplateInterface)) {
            throw new \Twig_Error_Loader(sprintf('Unexpected template type "%s" found for template "%s".', get_class($template), $name));
        }
        if ($template instanceof TranslatableTemplateInterface) {
            /** @var TranslatableTemplateInterface $template */
            $locale = $this->getCurrentLocale();
            $template->setCurrentLocale($locale);
        }

        return $template;
    }
853284
protected function getTemplate($name, array $data)
    {
        $template = App::instance()->template($name);

        if (!$template->exists()) {
            throw new Exception("The template '{$name}' does not exist.");
        }

        return $template->render($data);
    }
1025983
protected function getTemplate($template, $name)
    {
        // We begin by fetching the master migration stub.
        $stub = $this->file->get(__DIR__.'/templates/migration/migration.txt');

        // Next, set the migration class name
        $stub = str_replace('{{name}}', \Str::studly($name), $stub);

        // Now, we're going to handle the tricky
        // work of creating the Schema
        $upMethod = $this->getUpStub();
        $downMethod = $this->getDownStub();

        // Finally, replace the migration stub with the dynamic up and down methods
        $stub = str_replace('{{up}}', $upMethod, $stub);
        $stub = str_replace('{{down}}', $downMethod, $stub);

        return $stub;
    }
536343
public function getSource($name)
    {
        // Fetch the view from the database.
        $viewModel = Vpage::make($name);

        // If it is found return its content.
        if (! empty($viewModel)) {
            return $viewModel->content;
        }

        throw new Twig_Error_Loader('unable to locate page ' . $name);
    }
1116079
public static function getFormatTemplate($name) {
        $file = sprintf(
            '%s/Model/template/format/%s.html',
            __DIR__,
            $name
        );

        if (!file_exists($file)) {
            return null;
        }

        if (!isset(self::$templates[$name])) {
            self::$templates[$name] = file_get_contents($file);
        }

        return self::$templates[$name];
    }
51163
function load($name): string {
    if (!isset($this->views[$name])) {
      $cacheKey = [__CLASS__, $name];
      $viewRenderer = $this->viewRenderer;

      /** @var \yii\caching\Cache $cache */
      $cache = $viewRenderer->cache;
      if ($viewRenderer->enableCaching && $cache->exists($cacheKey))
        $output = $cache->get($cacheKey);
      else {
        $path = FileHelper::localize($this->findViewFile($name));
        if (!is_file($path)) throw new InvalidCallException("The view file '$path' does not exist.");

        $output = @file_get_contents($path);
        if ($viewRenderer->enableCaching) $cache->set($cacheKey, $output, $viewRenderer->cachingDuration);
      }

      $this->views[$name] = $output;
    }

    return $this->views[$name];
  }
500602
public function findTemplate(string $name): string
    {
        if (isset($this->cache[$name])) {
            return $this->cache[$name];
        }
        if (isset($this->errorCache[$name])) {
            throw new \InvalidArgumentException($this->errorCache[$name]);
        }

        list($namespace, $shortname) = $this->parseName($name);

        if (! isset($this->paths[$namespace])) {
            $this->errorCache[$name] = sprintf('There are no registered paths for namespace "%s".', $namespace);

            throw new \InvalidArgumentException($this->errorCache[$name]);
        }

        foreach ($this->paths[$namespace] as $path) {
            foreach ($this->getPossibleViewFiles($shortname) as $file) {
                if (is_file($viewPath = $path . '/' . $file)) {
                    if (false !== $realpath = realpath($viewPath)) {
                        return $this->cache[$name] = $realpath;
                    }

                    return $this->cache[$name] = $viewPath;
                }
            }
        }

        $this->errorCache[$name] = sprintf('Unable to find template "%s" (looked into: %s).', $name, implode(', ', $this->paths[$namespace]));

        throw new \InvalidArgumentException($this->errorCache[$name]);
    }
701900
protected function getViewContent($name)
    {
        if (!$stub = $this->getViewStub($name)) {
            return '';
        }

        return strtr($stub, $this->getCommonReplacements());
    }
736401
public function template($name)
    {
        $fullPath = $name . ".phtml";
        $directory = dirname($fullPath);

        $globalDirPath = $this->appPath . "/Templates/" . $directory;
        $fileName = $globalDirPath . "/" . basename($fullPath);

        if (!is_dir($globalDirPath)) {
            // Dir doesn't exist, make it
            mkdir($globalDirPath, 0777, true);
        }

        $contents = array('<!DOCTYPE html>');
        $contents[] = '<html>';
        $contents[] = '    <head>';
        $contents[] = '        <meta charset="utf-8"/>';
        $contents[] = '        <title></title>';
        $contents[] = '        <script type="text/javascript" src=""></script>';
        $contents[] = '        <link rel="stylesheet" type="text/css" href="">';
        $contents[] = '    </head>';
        $contents[] = '    <body>';
        $contents[] = '        <?php $this->content()?>';
        $contents[] = '    </body>';
        $contents[] = '</html>';

        if (file_put_contents($fileName, implode("\n", $contents))) {
            echo Utils::colorize('Create ' . $fileName, 'SUCCESS');

            return true;
        } else {
            echo Utils::colorize('Can\'t create ' . $fileName, 'FAILURE');

            return false;
        }
    }