Generate sources from templates.

@param string $path
@param array $arguments
514981
public function templateDirectory($path, array $arguments = [])
    {
        foreach ($this->allFiles($this->stubbox, $this->makePath($path)) as $stubbox_path) {
            if ($this->context->directory) {
                $outbox_path = substr($stubbox_path, strlen($this->context->directory) + 1);
            } else {
                $outbox_path = $stubbox_path;
            }
            $this->directory(dirname($outbox_path))->file(basename($outbox_path))->template($stubbox_path, $arguments);
        }
    }
605392
private function addTwigPath($path, array $options = [])
    {
        if ($path === 'templates' && $this->pathAdded) {
            return;
        }

        $app = $this->getContainer();

        $position = isset($options['position']) ? $options['position'] : 'append';
        $namespace = isset($options['namespace']) ? $options['namespace'] : FilesystemLoader::MAIN_NAMESPACE;

        $dir = $this->getBaseDirectory()->getDir($path);
        if (!$dir->exists()) {
            return;
        }
        try {
            if ($position === 'prepend') {
                $app['twig.loader.bolt_filesystem']->prependDir($dir, $namespace);
            } else {
                $app['twig.loader.bolt_filesystem']->addDir($dir, $namespace);
            }
        } catch (LoaderError $e) {
            $app['logger.system']->critical(sprintf('%s was unable to add the Twig path %s. %s', $this->getName(), $path, $e->getMessage()), ['event' => 'exception', 'exception' => $e]);
        }
    }
470377
public function createDirectory($path, $children = []) {
        $success = true;
        if (is_array($path)) {
            foreach ($path as $item) {
                $this->createDirectory($item);
            }
        } elseif (is_scalar($path)) {
            echo "\n Creating $path ";
            if (strpos($path, '/') !== false) {
                $pathParts = explode("/", $path);
                $path = '';
                foreach ($pathParts as $item) {
                    if (!empty($item)) {
                        $path .= $item;
                        if (!file_exists($path)) {
                            mkdir($path);
                        }
                        $path .= '/';
                    }
                }
            } else {
                if (file_exists($path)) {
                    $success = true;
                } else {
                    $success = mkdir($path);
                }
            }

            if (!$success) {
                throw new \Exception("Error creating $path");
            }

            if ($children) {
                foreach ($children as $item) {
                    $this->createDirectory($path . '/' . $item);
                }
            }
        }        
    }
1357256
public function compile($path)
	{
		$contents = $this->compileString($this->files->get($path));

		if ( ! is_null($this->cachePath))
		{
			$this->files->put($this->getCompiledPath($path), $contents);
		}
	}
1163285
public function add_template_directory($path, $namespace = null, $prepend = false) {
		$template_directory = [
			'directory' => $path,
			'namespace' => $namespace
		];

		if ($prepend) {
			array_unshift($this->template_directories, $template_directory);
		} else {
			array_push($this->template_directories, $template_directory);
		}
	}
238912
protected function _generateTree($path)
    {
        $paths = glob($path, GLOB_ONLYDIR);
        if (!$paths) {
            $paths = array();
        }
        array_unshift($paths, dirname($path));
        return $paths;
    }
304227
public function redirectToPath($path, $parameters = array())
    {
        $route = $this->getRouter()->generate($path, $parameters);

        return $this->redirect($route);
    }
334944
private function initPath($path, $args = null)
    {
        $this->info("Init directory '{$path}'");

        $repositoryUrl = trim(shell_exec("cd {$path} && git config --get remote.origin.url"));
        $packageName = $this->getPackageNameByRepositoryUrl($repositoryUrl);

        $this->initComposerJson($path, $repositoryUrl, $packageName);
        $this->initPackageClassPhp($path, $packageName);

        if (!$this->noTests) {
            $this->initPhpUnitXml($path);
            $this->initPackageClassTestPhp($path, $packageName);
        }

        if (!$this->noCi) {
            $this->initCodeclimateYml($path);
            $this->initTravisYml($path);
            $this->initStyleCiYml($path);
        }
    }
616611
function includeSource(path, options) {
  var opts = utils.shallowCopy({}, options)
    , includePath
    , template;
  if (!opts.filename) {
    throw new Error('`include` requires the \'filename\' option.');
  }
  includePath = exports.resolveInclude(path, opts.filename);
  template = fs.readFileSync(includePath).toString().replace(_BOM, '');

  opts.filename = includePath;
  var templ = new Template(template, opts);
  templ.generateSource();
  return {
    source: templ.source,
    filename: includePath,
    template: template
  };
}
175888
public function renderTemplate($path, array $data = [], $class = null)
    {
        if (file_exists($path)) {
            return $this->doRender($path, $data, $class);
        }
        throw new RuntimeException(__METHOD__.' needs a valid template path as first argument.');
    }
161111
public function setTemplatePath($path, \Twig_Environment $twig = null, $extensions = [])
    {
        $this->paths['templates'] = $path;

        if (is_null($twig) === true) {
            $loader = new \Twig_Loader_Filesystem($path);

            $twig = new \Twig_Environment($loader);
        }

        $twig->setExtensions($extensions);

        $this->injector->share($twig);

        return $this;
    }
498336
public function setPath(string $path)
    {
        $this->path = $path;
        
        // update path to templates and preload list of templates.
        $this->contentPath = $this->path . DIR_CONTENT_BASENAME;
        $this->templatesPath = $this->contentPath . DIR_TEMPLATES_BASENAME;
        
        $this->templates = File::listFilesRecursively($this->templatesPath, false, EXT_PART, EXT_PAGE);
    }
1360218
public function generate($path)
    {
        if ('tabs' === $this->config->get('indent', 'extra')) {
            $indent = "\t";
        } else {
            $indent = '    ';
        }

        $namespace = $this->config->get('namespace');

        foreach ($this->files as $file) {
            $class = $file->getClassDefinition();
            $source = $this->buildClass($class, $indent);

            $filename = ucfirst($class->getName()).'.zep.php';
            $filePath = $path.str_replace(
                $namespace,
                '',
                str_replace($namespace.'\\\\', \DIRECTORY_SEPARATOR, strtolower($class->getNamespace()))
            );
            $filePath = str_replace('\\', \DIRECTORY_SEPARATOR, $filePath);
            $filePath = str_replace(\DIRECTORY_SEPARATOR.\DIRECTORY_SEPARATOR, \DIRECTORY_SEPARATOR, $filePath);

            if (!is_dir($filePath)) {
                mkdir($filePath, 0777, true);
            }

            $filePath = realpath($filePath).'/';
            file_put_contents($filePath.$filename, $source);
        }
    }
1162549
protected function create(Array $arguments=[])
	{
		$migrationsDirectory = $this->cmd->getConfigOpt('migrations_storage');
		$templateTags = [];

		$migrationName = $this->cmd->question('Migration filename?');
		$filename = trim($migrationName);

		$path = $migrationsDirectory . '/' . $filename . '.php';

		if (file_exists($path)) {
			throw new MigrationFileInvalidException(
				sprintf(
					'Migration file [%s] exists.',
					$filename
				)
			);
		}

		$templateTags['phx:class'] = Helper::getQualifiedClassName($filename);

		$builder = new TemplateBuilder($this->cmd, $this->env);
		$builder->createClassTemplate('migration', $filename, $migrationsDirectory, $templateTags);

		// After migration class has been created, the record needs to go to the database and be set to pending.
		$model = new Model();
		$model->class_name = $templateTags['phx:class'];
		$model->status = Attribute::STATUS_PENDING;
		$model->path = $path;
		$model->save();

		$this->env->sendOutput('Created migration is now pending', 'green');
	}
763267
private function loadFormatsFromFile($path, array &$formats)
    {
        $folder = dirname($path);
        $file = basename($path);

        $locator = new FileLocator($folder);

        $xmlLoader10 = new XmlFormatLoader10($locator);
        $xmlLoader11 = new XmlFormatLoader11($locator);
        $xmlLoader10->setGlobalOptions($this->globalOptions);
        $xmlLoader11->setGlobalOptions($this->globalOptions);

        $resolver = new LoaderResolver([$xmlLoader10, $xmlLoader11]);
        $loader = new DelegatingLoader($resolver);

        $fileFormats = $loader->load($file);
        foreach ($fileFormats as $format) {
            if (array_key_exists($format['key'], $formats) && $formats[$format['key']] !== $format) {
                throw new InvalidArgumentException(
                    sprintf('Media format with key "%s" already exists!', $format['key'])
                );
            }

            $formats[$format['key']] = $format;
        }
    }
78969
public function makeImage($path, array $params)
    {
        $sourcePath = $this->getSourcePath($path);
        $cachedPath = $this->getCachePath($path, $params);

        if ($this->cacheFileExists($path, $params) === true) {
            return $cachedPath;
        }

        if ($this->sourceFileExists($path) === false) {
            throw new FileNotFoundException(
                'Could not find the image `'.$sourcePath.'`.'
            );
        }

        $source = $this->source->read(
            $sourcePath
        );

        if ($source === false) {
            throw new FilesystemException(
                'Could not read the image `'.$sourcePath.'`.'
            );
        }

        // We need to write the image to the local disk before
        // doing any manipulations. This is because EXIF data
        // can only be read from an actual file.
        $tmp = tempnam(sys_get_temp_dir(), 'Glide');

        if (file_put_contents($tmp, $source) === false) {
            throw new FilesystemException(
                'Unable to write temp file for `'.$sourcePath.'`.'
            );
        }

        try {
            $write = $this->cache->write(
                $cachedPath,
                $this->api->run($tmp, $this->getAllParams($params))
            );

            if ($write === false) {
                throw new FilesystemException(
                    'Could not write the image `'.$cachedPath.'`.'
                );
            }
        } catch (FileExistsException $exception) {
            // This edge case occurs when the target already exists
            // because it's currently be written to disk in another
            // request. It's best to just fail silently.
        } finally {
            unlink($tmp);
        }

        return $cachedPath;
    }
504090
private function ensureDirectoryExists($path)
    {
        if (!isset($this->resources[$path])) {
            // Recursively initialize parent directories
            if ($path !== '/') {
                $this->ensureDirectoryExists(Path::getDirectory($path));
            }

            $this->resources[$path] = new GenericResource($path);
            $this->resources[$path]->attachTo($this);

            return;
        }
    }