PHP code example of mattdanger / volt-helpers

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

    

mattdanger / volt-helpers example snippets


$di->set('view', function () use ($config) {

  $view = new View();
  // ...
  $view->registerEngines(array(
    '.volt' => function ($view, $di) use ($config) {

      $volt = new VoltEngine($view, $di);

      $volt->getCompiler()->addFunction('ordinal', function ($resolvedArgs, $expArgs) {
        return 'VoltHelpers\Helpers::ordinal(' . $resolvedArgs . ')';
      });
      $volt->getCompiler()->addFunction('strToCurrency', function ($resolvedArgs, $expArgs) {
        return 'VoltHelpers\Helpers::strToCurrency(' . $resolvedArgs . ')';
      });
      $volt->getCompiler()->addFunction('pluralize', function ($resolvedArgs, $expArgs) {
        return 'VoltHelpers\Helpers::pluralize(' . $resolvedArgs . ')';
      });
      $volt->getCompiler()->addFunction('paginationPath', function ($resolvedArgs, $expArgs) {
        return 'VoltHelpers\Helpers::paginationPath(' . $resolvedArgs . ')';
      });
      // ... 

      return $volt;
    },
    // ...
  ));

  return $view;

});