Skip to content

Commit 3f3348f

Browse files
committed
Added support for PRAGMA_FILTERS in mustache
1 parent 5aa2bfd commit 3f3348f

1 file changed

Lines changed: 30 additions & 6 deletions

File tree

ProcessMaker/Bpmn/MustacheOptions.php

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,33 +21,57 @@ public function __construct()
2121
];
2222
}
2323

24-
public function html64($text, Mustache_LambdaHelper $helper)
24+
public function html64($text, ?Mustache_LambdaHelper $helper = null)
2525
{
26+
if (!$helper) {
27+
// Support for PRAGMA_FILTERS
28+
return base64_encode('<html><body>' . $text . '</body></html>');
29+
}
2630
return base64_encode('<html><body>' . $helper->render($text) . '</body></html>');
2731
}
2832

29-
public function base64($text, Mustache_LambdaHelper $helper)
33+
public function base64($text, ?Mustache_LambdaHelper $helper = null)
3034
{
35+
if (!$helper) {
36+
// Support for PRAGMA_FILTERS
37+
return base64_encode($text);
38+
}
3139
return base64_encode($helper->render($text));
3240
}
3341

34-
public function key($text, Mustache_LambdaHelper $helper)
42+
public function key($text, ?Mustache_LambdaHelper $helper = null)
3543
{
44+
if (!$helper) {
45+
// Support for PRAGMA_FILTERS
46+
return urlencode(Hash::make($text));
47+
}
3648
return urlencode(Hash::make($helper->render($text)));
3749
}
3850

39-
public function json($text, Mustache_LambdaHelper $helper)
51+
public function json($text, ?Mustache_LambdaHelper $helper = null)
4052
{
53+
if (!$helper) {
54+
// Support for PRAGMA_FILTERS
55+
return json_encode($text);
56+
}
4157
return json_encode($helper->render($text));
4258
}
4359

44-
public function serialize($text, Mustache_LambdaHelper $helper)
60+
public function serialize($text, ?Mustache_LambdaHelper $helper = null)
4561
{
62+
if (!$helper) {
63+
// Support for PRAGMA_FILTERS
64+
return serialize($text);
65+
}
4666
return serialize($helper->render($text));
4767
}
4868

49-
public function xml($text, Mustache_LambdaHelper $helper)
69+
public function xml($text, ?Mustache_LambdaHelper $helper = null)
5070
{
71+
if (!$helper) {
72+
// Support for PRAGMA_FILTERS
73+
return xmlrpc_encode($text);
74+
}
5175
return xmlrpc_encode($helper->render($text));
5276
}
5377
}

0 commit comments

Comments
 (0)