Example #1
0
// TemplatePaths object: a subclass can be used if custom resolving is wanted.
$paths = $view->getTemplatePaths();
// Configuring paths: explicit setters used in this example. Paths can also
// be passed as a ["templateRootPaths" => ["path1/", "path2/"]] constructor
// argument for this implementation of TemplatePaths. When `TYPO3.Fluid`
// reads these paths they are read in reverse and the first matching file
// is used - meaning that if you have the same file in both `TemplatesA`
// and `TemplatesB` and render that using this MVC approach, you will be
// rendering the file located in `TemplatesB` becase this folder was last
// and is checked first (think of these paths as prioritised fallbacks).
$paths->setTemplateRootPaths(array(__DIR__ . '/../Resources/Private/Templates/'));
$paths->setLayoutRootPaths(array(__DIR__ . '/../Resources/Private/Layouts/'));
$paths->setPartialRootPaths(array(__DIR__ . '/../Resources/Private/Partials/'));
if ($FLUID_CACHE_DIRECTORY) {
    // Configure View's caching to use ./examples/cache/ as caching directory.
    $view->setCache(new \TYPO3Fluid\Fluid\Core\Cache\SimpleFileCache($FLUID_CACHE_DIRECTORY));
}
/**
 * Tiny helper that outputs a plain string in a nice way,
 * directly to console.
 *
 * @param string $content
 * @return void
 */
if (!function_exists('example_output')) {
    function example_output($content)
    {
        $content = trim($content);
        echo PHP_EOL . $content . PHP_EOL . PHP_EOL;
        echo '# Sir\'s template is rendered above (';
        echo number_format(strlen($content)) . ' bytes).' . PHP_EOL;