Explorar el Código

rule send arguments (#157)

Maxwell Geng hace 1 año
padre
commit
e23fdcc14f
Se han modificado 2 ficheros con 24 adiciones y 0 borrados
  1. 12 0
      manual/project_target.md
  2. 12 0
      zh-cn/manual/project_target.md

+ 12 - 0
manual/project_target.md

@@ -677,6 +677,18 @@ target("test")
     add_files("src/*.markdown")
 ```
 
+We can send arguments to rule in add_rules:
+
+```lua
+rule("my_rule")
+    on_load(function (target)
+        local my_arg = target:extraconf("rules", "my_rule", "my_arg") -- "my arg"
+    end)
+
+target("test")
+    add_rules("my_rule", { my_arg = "my arg"})
+```
+
 We can also specify the application of local files to the rules, see: [add_files](#targetadd_files).
 
 ### target:on_load

+ 12 - 0
zh-cn/manual/project_target.md

@@ -679,6 +679,18 @@ target("test")
     add_files("src/*.markdown")
 ```
 
+我们可以在add_rules时传参:
+
+```lua
+rule("my_rule")
+    on_load(function (target)
+        local my_arg = target:extraconf("rules", "my_rule", "my_arg") -- "my arg"
+    end)
+
+target("test")
+    add_rules("my_rule", { my_arg = "my arg"})
+```
+
 我们也可以指定应用局部文件到规则,具体使用见:[add_files](#targetadd_files)。
 
 ### target:on_load