Skip to content

docs: update automation documents #332

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions docs/user_docs/guides/automation.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,8 @@ app: App {
}
```

Note that when `name` of `app` is not in the `App` schema config, it will be added into the config after override.

#### Delete Configuration

Run the command to delete the `key` attribute of `labels`.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,8 @@ app: App {
}
```

注意当配置块中 `app` 的 `name` 属性不存在时, 它会被新增到配置块中。

#### 删除配置

执行如下命令可以删除 `labels` 中的 `key` 字段
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,7 @@ KCL 通过内置模块、系统库模块和插件模块提供工程化的扩展
<DocsCard header="file" href="file">
<p>提供了与文件系统相关的函数。</p>
</DocsCard>
<DocsCard header="template" href="template">
<p>提供了与模版相关的函数。</p>
</DocsCard>
</DocsCards>
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
---
title: "template"
linkTitle: "template"
type: "docs"
description: 模版操作
weight: 100
---

## execute

`execute(template: str, data: {str:any} = {}) -> str`

将解析过的模板应用于指定的数据对象,并返回字符串输出。查看 https://handlebarsjs.com/ 获取更多文档和示例。

```python3
import template

content = template.execute("""\
<div class="entry">
{{#if author}}
<h1>{{firstName}} {{lastName}}</h1>
{{/if}}
</div>
""", {
author: True,
firstName: "Yehuda",
lastName: "Katz",
})
```

## html_escape

`html_escape(data: str) -> str`

将字符 `&"<>` 替换为等效的 html / xml实体。

```python3

import template

content = template.html_escape("""\
<div class="entry">
{{#if author}}
<h1>{{firstName}} {{lastName}}</h1>
{{/if}}
</div>
""")
```
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,8 @@ app: App {
}
```

注意当配置块中 `app` 的 `name` 属性不存在时, 它会被新增到配置块中。

#### 删除配置

执行如下命令可以删除 `labels` 中的 `key` 字段
Expand Down
3 changes: 3 additions & 0 deletions versioned_docs/version-0.8/reference/model/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,7 @@ For relatively complex general logic, it is provided through the system modules.
<DocsCard header="file" href="file">
<p>Provides filesystem functions.</p>
</DocsCard>
<DocsCard header="template" href="template">
<p>Provides template functions.</p>
</DocsCard>
</DocsCards>
48 changes: 48 additions & 0 deletions versioned_docs/version-0.8/reference/model/template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
---
title: "template"
linkTitle: "template"
type: "docs"
description: template functions
weight: 100
---

## execute

`execute(template: str, data: {str:any} = {}) -> str`

Applies a parsed template to the specified data object and returns the string output. See https://handlebarsjs.com/ for more documents and examples.

```python3
import template

content = template.execute("""\
<div class="entry">
{{#if author}}
<h1>{{firstName}} {{lastName}}</h1>
{{/if}}
</div>
""", {
author: True,
firstName: "Yehuda",
lastName: "Katz",
})
```

## html_escape

`html_escape(data: str) -> str`

Replaces the characters `&"<>` with the equivalent html / xml entities.

```python3

import template

content = template.html_escape("""\
<div class="entry">
{{#if author}}
<h1>{{firstName}} {{lastName}}</h1>
{{/if}}
</div>
""")
```
2 changes: 2 additions & 0 deletions versioned_docs/version-0.8/user_docs/guides/automation.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,8 @@ app: App {
}
```

Note that when `name` of `app` is not in the `App` schema config, it will be added into the config after override.

#### Delete Configuration

Run the command to delete the `key` attribute of `labels`.
Expand Down