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
50
50
var a = 'Hello';
51
51
return 'RuleScript: $a World'; // RuleScript: Hello World
52
52
```
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
+ ```
53
62
54
63
More templates in ` test/src/Main.hx ` .
55
64
# Limitations
56
65
57
- - String interpolations don't support many functions.
66
+ - [ String interpolations] ( https://haxe.org/manual/lf-string-interpolation.html ) don't support many functions
58
67
- Script ` using ` callback supports max number of arguments is 8.
59
68
- [ Wildcard imports] ( https://haxe.org/manual/type-system-import.html#wildcard-import ) don't support.
60
69
Original file line number Diff line number Diff line change @@ -15,6 +15,16 @@ class HxParser extends Parser
15
15
super ();
16
16
}
17
17
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
+
18
28
override public function parse (code : String ): Expr
19
29
{
20
30
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 {}
17
17
* script = new RuleScript(null,new HxParser());
18
18
*
19
19
* // Get parser as HxParser
20
- * script.getParser(HxParser).allowJSON = true ;
20
+ * script.getParser(HxParser).allowAll() ;
21
21
*
22
22
* // Run execute inside try-catch
23
23
* script.tryExecute('trace("Hello World");'); // Hello World
Original file line number Diff line number Diff line change @@ -12,9 +12,7 @@ class Main
12
12
{
13
13
script = new RuleScript (null , new HxParser ());
14
14
15
- var parser = script .getParser (HxParser ).parser ;
16
-
17
- parser .allowJSON = parser .allowMetadata = parser .allowTypes = true ;
15
+ script .getParser (HxParser ).allowAll ();
18
16
19
17
trace (' Testing Commands:' );
20
18
You can’t perform that action at this time.
0 commit comments