You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+2Lines changed: 2 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -65,7 +65,9 @@ echo $template(['first' => 'John']); // Error: Runtime: [last] does not exist
65
65
*`ignoreStandalone`: Disables standalone tag removal. When set, blocks and partials that are on their own line will not remove the whitespace on that line.
66
66
*`explicitPartialContext`: Disables implicit context for partials. When enabled, partials that are not passed a context value will execute against an empty object.
67
67
*`helpers`: Provide a key => value array of custom helper functions.
68
+
*`helperResolver`: A closure which will be called for any helper not in the `helpers` array to return a function for it.
68
69
*`partials`: Provide a key => value array of custom partial templates.
70
+
*`partialResolver`: A closure which will be called for any partial not in the `partials` array to return a template for it.
Copy file name to clipboardExpand all lines: tests/RegressionTest.php
+34Lines changed: 34 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -2,6 +2,7 @@
2
2
3
3
namespaceDevTheorem\Handlebars\Test;
4
4
5
+
useDevTheorem\Handlebars\Context;
5
6
useDevTheorem\Handlebars\Handlebars;
6
7
useDevTheorem\Handlebars\HelperOptions;
7
8
useDevTheorem\Handlebars\Options;
@@ -829,6 +830,29 @@ public static function issueProvider(): array
829
830
'expected' => '3',
830
831
],
831
832
833
+
[
834
+
'id' => 201,
835
+
'template' => '{{foo "world"}}',
836
+
'options' => newOptions(
837
+
helperResolver: function () {
838
+
returnfn(string$name) => "Hello, $name";
839
+
},
840
+
),
841
+
'expected' => 'Hello, world',
842
+
],
843
+
[
844
+
'id' => 201,
845
+
'template' => '{{#foo "test"}}World{{/foo}}',
846
+
'options' => newOptions(
847
+
helperResolver: function (Context$cx, string$name) {
848
+
returnfunction ($name, HelperOptions$options) {
849
+
return"$name = " . $options->fn();
850
+
};
851
+
},
852
+
),
853
+
'expected' => 'test = World',
854
+
],
855
+
832
856
[
833
857
'id' => 204,
834
858
'template' => '{{#> test name="A"}}B{{/test}}{{#> test name="C"}}D{{/test}}',
@@ -2030,6 +2054,16 @@ public static function issueProvider(): array
2030
2054
'expected' => 'inline\'partial',
2031
2055
],
2032
2056
2057
+
[
2058
+
'template' => '{{>foo}} and {{>bar}}',
2059
+
'options' => newOptions(
2060
+
partialResolver: function (Context$context, string$name) {
2061
+
return"PARTIAL: $name";
2062
+
},
2063
+
),
2064
+
'expected' => 'PARTIAL: foo and PARTIAL: bar',
2065
+
],
2066
+
2033
2067
[
2034
2068
'template' => "{{#> testPartial}}\n ERROR: testPartial is not found!\n {{#> innerPartial}}\n ERROR: innerPartial is not found!\n ERROR: innerPartial is not found!\n {{/innerPartial}}\n ERROR: testPartial is not found!\n {{/testPartial}}",
2035
2069
'expected' => " ERROR: testPartial is not found!\n ERROR: innerPartial is not found!\n ERROR: innerPartial is not found!\n ERROR: testPartial is not found!\n",
0 commit comments