Skip to content

Commit

Permalink
[ENG-262] Support mustache filters pragma by default.
Browse files Browse the repository at this point in the history
  • Loading branch information
heathdutton committed Jun 13, 2018
1 parent e3dd27b commit 13759ff
Showing 1 changed file with 23 additions and 23 deletions.
46 changes: 23 additions & 23 deletions Helper/TokenHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,29 @@ class TokenHelper
public function __construct(CoreParametersHelper $coreParametersHelper)
{
try {
$this->engine = new Engine();
$this->engine = new Engine(['pragmas' => [Engine::PRAGMA_FILTERS]]);
$this->engine->addHelper(
'lpad',
[
'2' => function ($value) {
return str_pad((string) $value, 2, '0', STR_PAD_LEFT);
},
'4' => function ($value) {
return str_pad((string) $value, 4, '0', STR_PAD_LEFT);
},
]
);
$this->engine->addHelper(
'rpad',
[
'2' => function ($value) {
return str_pad((string) $value, 2, '0', STR_PAD_RIGHT);
},
'4' => function ($value) {
return str_pad((string) $value, 4, '0', STR_PAD_RIGHT);
},
]
);
} catch (\Exception $e) {
throw new \Exception('You may need to install Mustache via "composer require mustache/mustache".', 0, $e);
}
Expand Down Expand Up @@ -116,28 +138,6 @@ public function setTimezones($timzoneSource = 'UTC', $timzoneDestination = 'UTC'
{
$this->dateFormatHelper = new DateFormatHelper($timzoneSource, $timzoneDestination);
$this->engine->addHelper('date', $this->dateFormatHelper);
$this->engine->addHelper(
'lpad',
[
'2' => function ($value) {
return str_pad((string) $value, 2, '0', STR_PAD_LEFT);
},
'4' => function ($value) {
return str_pad((string) $value, 4, '0', STR_PAD_LEFT);
},
]
);
$this->engine->addHelper(
'rpad',
[
'2' => function ($value) {
return str_pad((string) $value, 2, '0', STR_PAD_RIGHT);
},
'4' => function ($value) {
return str_pad((string) $value, 4, '0', STR_PAD_RIGHT);
},
]
);

return $this;
}
Expand Down

0 comments on commit 13759ff

Please sign in to comment.