File tree Expand file tree Collapse file tree 4 files changed +22
-5
lines changed
Expand file tree Collapse file tree 4 files changed +22
-5
lines changed Original file line number Diff line number Diff line change @@ -50,11 +50,20 @@ RuleScript supports [String Interpolation](https://haxe.org/manual/lf-string-int
5050var a = 'Hello';
5151return 'RuleScript: $a World'; // RuleScript: Hello World
5252```
53+ ``` haxe
54+ var a = {
55+ a:'RuleScript',
56+ b: () -> 'Hello',
57+ c:'World'
58+ };
59+
60+ return '${a.a}: ${a.b() + " " + a.c}'; // RuleScript: Hello World
61+ ```
5362
5463More templates in ` test/src/Main.hx ` .
5564# Limitations
5665
57- - String interpolations don't support many functions.
66+ - [ String interpolations] ( https://haxe.org/manual/lf-string-interpolation.html ) don't support many functions
5867- Script ` using ` callback supports max number of arguments is 8.
5968- [ Wildcard imports] ( https://haxe.org/manual/type-system-import.html#wildcard-import ) don't support.
6069
Original file line number Diff line number Diff line change @@ -15,6 +15,16 @@ class HxParser extends Parser
1515 super ();
1616 }
1717
18+ inline public function allowAll (): Void
19+ setParams (true , true , true );
20+
21+ public function setParams (? allowJSON : Bool , ? allowMetadata : Bool , ? allowTypes : Bool )
22+ {
23+ parser .allowJSON = allowJSON ;
24+ parser .allowMetadata = allowMetadata ;
25+ parser .allowTypes = allowTypes ;
26+ }
27+
1828 override public function parse (code : String ): Expr
1929 {
2030 return parser .parseString (code , ' rulescript:HxParser' , 0 );
Original file line number Diff line number Diff line change @@ -17,7 +17,7 @@ abstract StringOrExpr(Dynamic) from String to String from Expr to Expr {}
1717 * script = new RuleScript(null,new HxParser());
1818 *
1919 * // Get parser as HxParser
20- * script.getParser(HxParser).allowJSON = true ;
20+ * script.getParser(HxParser).allowAll() ;
2121 *
2222 * // Run execute inside try-catch
2323 * script.tryExecute('trace("Hello World");'); // Hello World
Original file line number Diff line number Diff line change @@ -12,9 +12,7 @@ class Main
1212 {
1313 script = new RuleScript (null , new HxParser ());
1414
15- var parser = script .getParser (HxParser ).parser ;
16-
17- parser .allowJSON = parser .allowMetadata = parser .allowTypes = true ;
15+ script .getParser (HxParser ).allowAll ();
1816
1917 trace (' Testing Commands:' );
2018
You can’t perform that action at this time.
0 commit comments