Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 30 additions & 6 deletions ProcessMaker/Bpmn/MustacheOptions.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,33 +21,57 @@ public function __construct()
];
}

public function html64($text, Mustache_LambdaHelper $helper)
public function html64($text, ?Mustache_LambdaHelper $helper = null)
{
if (!$helper) {
// Support for PRAGMA_FILTERS
return base64_encode('<html><body>' . $text . '</body></html>');
}
return base64_encode('<html><body>' . $helper->render($text) . '</body></html>');
}

public function base64($text, Mustache_LambdaHelper $helper)
public function base64($text, ?Mustache_LambdaHelper $helper = null)
{
if (!$helper) {
// Support for PRAGMA_FILTERS
return base64_encode($text);
}
return base64_encode($helper->render($text));
}

public function key($text, Mustache_LambdaHelper $helper)
public function key($text, ?Mustache_LambdaHelper $helper = null)
{
if (!$helper) {
// Support for PRAGMA_FILTERS
return urlencode(Hash::make($text));
}
return urlencode(Hash::make($helper->render($text)));
}

public function json($text, Mustache_LambdaHelper $helper)
public function json($text, ?Mustache_LambdaHelper $helper = null)
{
if (!$helper) {
// Support for PRAGMA_FILTERS
return json_encode($text);
}
return json_encode($helper->render($text));
}

public function serialize($text, Mustache_LambdaHelper $helper)
public function serialize($text, ?Mustache_LambdaHelper $helper = null)
{
if (!$helper) {
// Support for PRAGMA_FILTERS
return serialize($text);
}
return serialize($helper->render($text));
}

public function xml($text, Mustache_LambdaHelper $helper)
public function xml($text, ?Mustache_LambdaHelper $helper = null)
{
if (!$helper) {
// Support for PRAGMA_FILTERS
return xmlrpc_encode($text);
}
return xmlrpc_encode($helper->render($text));
}
}
2 changes: 1 addition & 1 deletion ProcessMaker/Models/MustacheExpressionEvaluator.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class MustacheExpressionEvaluator implements TemplateExpressionInterface

public function __construct(array $options = [])
{
$this->engine = new Mustache_Engine($options);
$this->engine = app(Mustache_Engine::class, $options);
}

/**
Expand Down
3 changes: 2 additions & 1 deletion ProcessMaker/Providers/WorkflowServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -201,12 +201,13 @@ function (ThrowEventInterface $source, EventDefinitionInterface $sourceEventDefi
/**
* Mustache Engine
*/
$this->app->bind(Mustache_Engine::class, function () {
$this->app->bind(Mustache_Engine::class, function ($app, $params) {
$op = new MustacheOptions;

return new Mustache_Engine([
'helpers' => $op->helpers,
'pragmas' => [Mustache_Engine::PRAGMA_FILTERS],
...($params['options'] ?? []),
]);
});

Expand Down
Loading