NetLife Guru

Setting Directories for Templates and Cache

When creating a new instance of the template engine, you can specify the directories for your templates and cache. This is particularly useful if you have a custom project structure.

Here's how you can set custom directories:

    $templateEngine = new Nlg\Aurora\Loader([
        'views' => '/views',
        'cache' => '/cache',
    ]);

In this example, the engine will look for template files (*.html) in the '/templates' directory and store the cache files in the '/cacheStorage' directory.

Default Settings

If you don't specify these directories, the engine will use the default settings:

These default settings work well for most basic projects, but you might want to customize them as your project grows.

Full snippet:

    <?php

    require_once "../src/aurora.php";

    $templateEngine = new Nlg\Aurora\Loader([
        'views' => '/views',
        'cache' => '/cache',
    ]);

    $templateEngine->setFiles([
	    'index.html'
    ]);

    $templateEngine->createCache(true);

    print $templateEngine->render("layout");