Skip to content
This repository was archived by the owner on Jul 14, 2025. It is now read-only.

Commit 3f823bd

Browse files
committed
docs: update .gitignore and enhance template documentation with toJSON function examples in multiple languages
1 parent 87248ce commit 3f823bd

File tree

9 files changed

+178
-1
lines changed

9 files changed

+178
-1
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,5 @@ npm-debug.log*
1919
yarn-debug.log*
2020
yarn-error.log*
2121

22-
.cursor/
22+
.cursor/
23+
temp

docs/configuration/templates.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,23 @@ responseBody: |-
103103
endpoint: "http://localhost:5236/users/{{.Args.email}}/preferences"
104104
```
105105

106+
### 8. 处理复杂对象数据
107+
108+
当需要将请求或者响应的对象、数组之类的复杂结构转成JSON的话,可以使用 `toJSON` 函数:
109+
110+
```yaml
111+
requestBody: |-
112+
{
113+
"isPublic": {{.Args.isPublic}},
114+
"showEmail": {{.Args.showEmail}},
115+
"theme": "{{.Args.theme}}",
116+
"tags": {{.Args.tags}},
117+
"settings": {{ toJSON .Args.settings }}
118+
}
119+
```
120+
121+
此处的`settings`是一个复杂对象,使用`toJSON`函数后,会自动将`settings`转换为JSON字符串
122+
106123
## 内置函数
107124

108125
目前支持以下内置函数:
@@ -122,6 +139,11 @@ endpoint: "http://localhost:5236/users/{{.Args.email}}/preferences"
122139
{{- $rows := fromJSON .Response.Data.rows }}
123140
```
124141

142+
4. `toJSON`: 将对象转换为 JSON 字符串
143+
```yaml
144+
"settings": {{ toJSON .Args.settings }}
145+
```
146+
125147
如果需要添加新的模板函数,可以
126148
1. 描述具体的使用场景,创建 issue 说明需求
127149
3. 欢迎实现后PR,但目前只接受通用用途的函数

i18n/de/docusaurus-plugin-content-docs/current/configuration/templates.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,23 @@ Dieses Beispiel zeigt:
103103
endpoint: "http://localhost:5236/users/{{.Args.email}}/preferences"
104104
```
105105

106+
### 8. Komplexe Objektdaten verarbeiten
107+
108+
Wenn Sie komplexe Strukturen wie Objekte oder Arrays in Anfragen oder Antworten in JSON umwandeln müssen, können Sie die Funktion `toJSON` verwenden:
109+
110+
```yaml
111+
requestBody: |-
112+
{
113+
"isPublic": {{.Args.isPublic}},
114+
"showEmail": {{.Args.showEmail}},
115+
"theme": "{{.Args.theme}}",
116+
"tags": {{.Args.tags}},
117+
"settings": {{ toJSON .Args.settings }}
118+
}
119+
```
120+
121+
In diesem Fall ist `settings` ein komplexes Objekt, das mit der Funktion `toJSON` automatisch in einen JSON-String umgewandelt wird.
122+
106123
## Eingebaute Funktionen
107124

108125
Aktuell unterstützte eingebaute Funktionen:
@@ -122,6 +139,11 @@ Aktuell unterstützte eingebaute Funktionen:
122139
{{- $rows := fromJSON .Response.Data.rows }}
123140
```
124141

142+
4. `toJSON`: Objekt in JSON-String konvertieren
143+
```yaml
144+
"settings": {{ toJSON .Args.settings }}
145+
```
146+
125147
Um neue Template-Funktionen hinzuzufügen:
126148
1. Spezifischen Anwendungsfall beschreiben und ein Issue erstellen
127149
2. PR-Beiträge sind willkommen, aber derzeit werden nur allgemeine Funktionen akzeptiert

i18n/en/docusaurus-plugin-content-docs/current/configuration/templates.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,23 @@ This example demonstrates:
103103
endpoint: "http://localhost:5236/users/{{.Args.email}}/preferences"
104104
```
105105

106+
### 8. Handling Complex Object Data
107+
108+
When you need to convert complex structures like objects or arrays in requests or responses to JSON, you can use the `toJSON` function:
109+
110+
```yaml
111+
requestBody: |-
112+
{
113+
"isPublic": {{.Args.isPublic}},
114+
"showEmail": {{.Args.showEmail}},
115+
"theme": "{{.Args.theme}}",
116+
"tags": {{.Args.tags}},
117+
"settings": {{ toJSON .Args.settings }}
118+
}
119+
```
120+
121+
In this case, `settings` is a complex object that will be automatically converted to a JSON string using the `toJSON` function.
122+
106123
## Built-in Functions
107124

108125
Currently supported built-in functions:
@@ -122,6 +139,11 @@ Currently supported built-in functions:
122139
{{- $rows := fromJSON .Response.Data.rows }}
123140
```
124141

142+
4. `toJSON`: Convert an object to a JSON string
143+
```yaml
144+
"settings": {{ toJSON .Args.settings }}
145+
```
146+
125147
To add new template functions:
126148
1. Describe the specific use case and create an issue
127149
2. Welcome PR contributions, but currently only accepting general-purpose functions

i18n/es/docusaurus-plugin-content-docs/current/configuration/templates.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,23 @@ Este ejemplo demuestra:
103103
endpoint: "http://localhost:5236/users/{{.Args.email}}/preferences"
104104
```
105105

106+
### 8. Manejar datos de objetos complejos
107+
108+
Cuando necesites convertir estructuras complejas como objetos o arrays en solicitudes o respuestas a JSON, puedes usar la función `toJSON`:
109+
110+
```yaml
111+
requestBody: |-
112+
{
113+
"isPublic": {{.Args.isPublic}},
114+
"showEmail": {{.Args.showEmail}},
115+
"theme": "{{.Args.theme}}",
116+
"tags": {{.Args.tags}},
117+
"settings": {{ toJSON .Args.settings }}
118+
}
119+
```
120+
121+
En este caso, `settings` es un objeto complejo que será convertido automáticamente a una cadena JSON usando la función `toJSON`.
122+
106123
## Funciones incorporadas
107124

108125
Funciones incorporadas actualmente soportadas:
@@ -122,6 +139,11 @@ Funciones incorporadas actualmente soportadas:
122139
{{- $rows := fromJSON .Response.Data.rows }}
123140
```
124141

142+
4. `toJSON`: Convertir un objeto a cadena JSON
143+
```yaml
144+
"settings": {{ toJSON .Args.settings }}
145+
```
146+
125147
Para agregar nuevas funciones de plantilla:
126148
1. Describir el caso de uso específico y crear un issue
127149
2. Se aceptan contribuciones PR, pero actualmente solo se aceptan funciones de propósito general

i18n/fr/docusaurus-plugin-content-docs/current/configuration/templates.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,23 @@ Cet exemple démontre :
103103
endpoint: "http://localhost:5236/users/{{.Args.email}}/preferences"
104104
```
105105

106+
### 8. Traitement des données d'objets complexes
107+
108+
Lorsque vous devez convertir des structures complexes comme des objets ou des tableaux dans les requêtes ou les réponses en JSON, vous pouvez utiliser la fonction `toJSON` :
109+
110+
```yaml
111+
requestBody: |-
112+
{
113+
"isPublic": {{.Args.isPublic}},
114+
"showEmail": {{.Args.showEmail}},
115+
"theme": "{{.Args.theme}}",
116+
"tags": {{.Args.tags}},
117+
"settings": {{ toJSON .Args.settings }}
118+
}
119+
```
120+
121+
Dans ce cas, `settings` est un objet complexe qui sera automatiquement converti en chaîne JSON à l'aide de la fonction `toJSON`.
122+
106123
## Fonctions intégrées
107124

108125
Fonctions intégrées actuellement supportées :
@@ -122,6 +139,11 @@ Fonctions intégrées actuellement supportées :
122139
{{- $rows := fromJSON .Response.Data.rows }}
123140
```
124141

142+
4. `toJSON`: Convertir un objet en chaîne JSON
143+
```yaml
144+
"settings": {{ toJSON .Args.settings }}
145+
```
146+
125147
Pour ajouter de nouvelles fonctions de template :
126148
1. Décrire le cas d'utilisation spécifique et créer un issue
127149
2. Les contributions PR sont les bienvenues, mais seules les fonctions à usage général sont actuellement acceptées

i18n/hi/docusaurus-plugin-content-docs/current/configuration/templates.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,23 @@ responseBody: |-
103103
endpoint: "http://localhost:5236/users/{{.Args.email}}/preferences"
104104
```
105105

106+
### 8. जटिल ऑब्जेक्ट डेटा का संचालन
107+
108+
जब आपको अनुरोध या प्रतिक्रियाओं में ऑब्जेक्ट या एरे जैसी जटिल संरचनाओं को JSON में बदलने की आवश्यकता होती है, तो आप `toJSON` फ़ंक्शन का उपयोग कर सकते हैं:
109+
110+
```yaml
111+
requestBody: |-
112+
{
113+
"isPublic": {{.Args.isPublic}},
114+
"showEmail": {{.Args.showEmail}},
115+
"theme": "{{.Args.theme}}",
116+
"tags": {{.Args.tags}},
117+
"settings": {{ toJSON .Args.settings }}
118+
}
119+
```
120+
121+
इस मामले में, `settings` एक जटिल ऑब्जेक्ट है जिसे `toJSON` फ़ंक्शन का उपयोग करके स्वचालित रूप से JSON स्ट्रिंग में बदल दिया जाएगा।
122+
106123
## अंतर्निहित फ़ंक्शन
107124

108125
वर्तमान में समर्थित अंतर्निहित फ़ंक्शन:
@@ -122,6 +139,11 @@ endpoint: "http://localhost:5236/users/{{.Args.email}}/preferences"
122139
{{- $rows := fromJSON .Response.Data.rows }}
123140
```
124141

142+
4. `toJSON`: ऑब्जेक्ट को JSON स्ट्रिंग में बदलें
143+
```yaml
144+
"settings": {{ toJSON .Args.settings }}
145+
```
146+
125147
नए टेम्पलेट फ़ंक्शन जोड़ने के लिए:
126148
1. विशिष्ट उपयोग के मामले का वर्णन करें और एक issue बनाएं
127149
2. PR योगदान का स्वागत है, लेकिन वर्तमान में केवल सामान्य उद्देश्य वाले फ़ंक्शन स्वीकार किए जाते हैं

i18n/ja/docusaurus-plugin-content-docs/current/configuration/templates.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,23 @@ responseBody: |-
103103
endpoint: "http://localhost:5236/users/{{.Args.email}}/preferences"
104104
```
105105

106+
### 8. 複雑なオブジェクトデータの処理
107+
108+
リクエストやレスポンスの複雑なオブジェクトや配列などの構造をJSONに変換する必要がある場合は、`toJSON`関数を使用できます:
109+
110+
```yaml
111+
requestBody: |-
112+
{
113+
"isPublic": {{.Args.isPublic}},
114+
"showEmail": {{.Args.showEmail}},
115+
"theme": "{{.Args.theme}}",
116+
"tags": {{.Args.tags}},
117+
"settings": {{ toJSON .Args.settings }}
118+
}
119+
```
120+
121+
この場合、`settings`は複雑なオブジェクトであり、`toJSON`関数を使用すると自動的にJSON文字列に変換されます。
122+
106123
## 組み込み関数
107124

108125
現在サポートされている組み込み関数:
@@ -122,6 +139,11 @@ endpoint: "http://localhost:5236/users/{{.Args.email}}/preferences"
122139
{{- $rows := fromJSON .Response.Data.rows }}
123140
```
124141

142+
4. `toJSON`: オブジェクトをJSON文字列に変換
143+
```yaml
144+
"settings": {{ toJSON .Args.settings }}
145+
```
146+
125147
新しいテンプレート関数を追加するには:
126148
1. 具体的な使用例を説明し、issue を作成
127149
2. PR の貢献を歓迎しますが、現在は汎用的な関数のみを受け付けています

i18n/ko/docusaurus-plugin-content-docs/current/configuration/templates.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,23 @@ responseBody: |-
103103
endpoint: "http://localhost:5236/users/{{.Args.email}}/preferences"
104104
```
105105

106+
### 8. 복잡한 객체 데이터 처리
107+
108+
요청이나 응답의 복잡한 객체, 배열과 같은 구조를 JSON으로 변환해야 할 때는 `toJSON` 함수를 사용할 수 있습니다:
109+
110+
```yaml
111+
requestBody: |-
112+
{
113+
"isPublic": {{.Args.isPublic}},
114+
"showEmail": {{.Args.showEmail}},
115+
"theme": "{{.Args.theme}}",
116+
"tags": {{.Args.tags}},
117+
"settings": {{ toJSON .Args.settings }}
118+
}
119+
```
120+
121+
이 경우, `settings`는 복잡한 객체로, `toJSON` 함수를 사용하면 자동으로 JSON 문자열로 변환됩니다.
122+
106123
## 내장 함수
107124

108125
현재 지원되는 내장 함수:
@@ -122,6 +139,11 @@ endpoint: "http://localhost:5236/users/{{.Args.email}}/preferences"
122139
{{- $rows := fromJSON .Response.Data.rows }}
123140
```
124141

142+
4. `toJSON`: 객체를 JSON 문자열로 변환
143+
```yaml
144+
"settings": {{ toJSON .Args.settings }}
145+
```
146+
125147
새로운 템플릿 함수를 추가하려면:
126148
1. 구체적인 사용 사례를 설명하고 issue 생성
127149
2. PR 기여를 환영하지만, 현재는 일반적인 용도의 함수만 수락합니다

0 commit comments

Comments
 (0)