PHP code example of minicli / stencil

1. Go to this page and download the library: Download minicli/stencil 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/ */

    

minicli / stencil example snippets




$stencil = new Stencil(__DIR__ . '/stencils');

$values = [
    'name' => 'Stencil',
    'description' => 'minimalist, dummy template generator.'
];

$parsedContent = $stencil->applyTemplate('mytemplate', $values);
var_dump($parsedContent);


$stencil = new Stencil(__DIR__ . '/stencils');
$template = 'mytemplate';
$values = [];
$variables = $stencil->scanTemplateVars($template);

echo "Building template $template\n";
foreach ($variables as $variable) {
    echo ucfirst($variable);
    $values[$variable] = readline(': ');
}

echo $stencil->applyTemplate($template, $values);