Browse Source

feat(templates): several fixes for sink data templates
1. Detailed docs for data templates and related docs
2. Add functions support in data templates

RockyJin 4 years atrás
parent
commit
66a11f8561
2 changed files with 4 additions and 4 deletions
  1. 2 2
      docs/en_US/rules/data_template.md
  2. 2 2
      docs/zh_CN/rules/data_template.md

+ 2 - 2
docs/en_US/rules/data_template.md

@@ -91,7 +91,7 @@ Golang 还内置提供了一些函数,用户可以参考[更多 Golang 内置
 在上述的数据模版中,使用了 `{{if pipeline}} T1 {{else if pipeline}} T0 {{end}}` 的内置动作,看上去比较复杂,稍微调整一下,去掉转义并加入缩进后排版如下(注意:在生成 Kuiper 规则的时候,不能传入以下优化后排版的规则)。
 
 ```
-{"device_id": {{.device_id}}, "description\": "
+{"device_id": {{.device_id}}, "description": "
   {{if lt .t_av 30.0}}
     Current temperature is {{.t_av}}, it's normal."
   {{else if ge .t_av 30.0}}
@@ -146,7 +146,7 @@ Golang 还内置提供了一些函数,用户可以参考[更多 Golang 内置
 
 - `{\"device_id\": \"{{.device_id}}\", \"description\": [` 这一段模版在作用到样例数据后,生成了 JSON 串 `{"device_id": "1", "description": [ `
 
-- `{{range $index, $ele := .values}} {{if le .temperature 25.0}}\"fine\"{{else if gt .temperature 25.0}}\"high\"{{end}} {{if eq $loopsize $index}}]{{else}},{{end}}{{end}}` ,这一段模版看起来比较复杂,但是如果如果把它调整一下,去掉转义并加入缩进后排版如下,看起来可能会更加清晰(注意:在生成 Kuiper 规则的时候,不能传入以下优化后排版的规则)。
+- `{{range $index, $ele := .values}} {{if le .temperature 25.0}}\"fine\"{{else if gt .temperature 25.0}}\"high\"{{end}} {{if eq $loopsize $index}}]{{else}},{{end}}{{end}}` ,这一段模版看起来比较复杂,但是如果把它调整一下,去掉转义并加入缩进后排版如下,看起来可能会更加清晰(注意:在生成 Kuiper 规则的时候,不能传入以下优化后排版的规则)。
 
   ```
   {{range $index, $ele := .values}} 

+ 2 - 2
docs/zh_CN/rules/data_template.md

@@ -89,7 +89,7 @@ Golang 还内置提供了一些函数,用户可以参考[更多 Golang 内置
 在上述的数据模版中,使用了 `{{if pipeline}} T1 {{else if pipeline}} T0 {{end}}` 的内置动作,看上去比较复杂,稍微调整一下,去掉转义并加入缩进后排版如下(注意:在生成 Kuiper 规则的时候,不能传入以下优化后排版的规则)。
 
 ```
-{"device_id": {{.device_id}}, "description\": "
+{"device_id": {{.device_id}}, "description": "
   {{if lt .t_av 30.0}}
     Current temperature is {{.t_av}}, it's normal."
   {{else if ge .t_av 30.0}}
@@ -144,7 +144,7 @@ Golang 还内置提供了一些函数,用户可以参考[更多 Golang 内置
 
 - `{\"device_id\": \"{{.device_id}}\", \"description\": [` 这一段模版在作用到样例数据后,生成了 JSON 串 `{"device_id": "1", "description": [ `
 
-- `{{range $index, $ele := .values}} {{if le .temperature 25.0}}\"fine\"{{else if gt .temperature 25.0}}\"high\"{{end}} {{if eq $loopsize $index}}]{{else}},{{end}}{{end}}` ,这一段模版看起来比较复杂,但是如果如果把它调整一下,去掉转义并加入缩进后排版如下,看起来可能会更加清晰(注意:在生成 Kuiper 规则的时候,不能传入以下优化后排版的规则)。
+- `{{range $index, $ele := .values}} {{if le .temperature 25.0}}\"fine\"{{else if gt .temperature 25.0}}\"high\"{{end}} {{if eq $loopsize $index}}]{{else}},{{end}}{{end}}` ,这一段模版看起来比较复杂,但是如果把它调整一下,去掉转义并加入缩进后排版如下,看起来可能会更加清晰(注意:在生成 Kuiper 规则的时候,不能传入以下优化后排版的规则)。
 
   ```
   {{range $index, $ele := .values}}