PHP code example of stillat / statamic-template-resolver

1. Go to this page and download the library: Download stillat/statamic-template-resolver library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

stillat / statamic-template-resolver example snippets




use Stillat\StatamicTemplateResolver\StringTemplateManager;

$manager = new StringTemplateManager(
    resource_path('views/social_media_images')
);



// ...

if ($manager->hasTemplate($collection, $blueprint)) {
    // The template exists.
}




// ...

$results = $manager->render(
    'colllection_handle',
    'blueprint_handle',
    $data
);




// Modify the template before its rendered.
$results = $manager->render(
    'collection_handle',
    'blueprint_handle',
    $data,
    function ($template, $data) {
        return mb_strtoupper($template);
    }
);