2017 © Pedro Peláez
 

library volt-helpers

Useful additions to the Volt template engine

image

mattdanger/volt-helpers

Useful additions to the Volt template engine

  • Wednesday, April 13, 2016
  • by mattdanger
  • Repository
  • 1 Watchers
  • 0 Stars
  • 465 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 130 % Grown

The README.md

VoltHelpers\Helpers

Useful additions to the Volt template engine, (*1)

Installing

Install using Composer:, (*2)

{
    "require": {
        "mattdanger/volt-helpers": "dev-master"
    }
}

You'll also need to add each function to the Volt service:, (*3)

$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;

});

Using Helpers

Here's a list of what's included:, (*4)

ordinal($number), (*5)

Number ordinal service - returns 1st, 2nd, 10th, 43rd, 724th, etc., (*6)

strToCurrency($value), (*7)

Output a string in currency format, (*8)

pluralize($count, $singular, $plural), (*9)

Pluralize string, (*10)

paginationPath(), (*11)

Returns a URL encoded string with current request params plus a param for current pagination page number., (*12)

The Versions

13/04 2016

dev-master

9999999-dev https://github.com/mattdanger/volt-helpers

Useful additions to the Volt template engine

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

phalcon volt

13/04 2016

v1.0

1.0.0.0 https://github.com/mattdanger/volt-helpers

Useful additions to the Volt template engine

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

phalcon volt