diff --git a/en/develop-plugin/dev-guides-and-walkthroughs/trigger-plugin.mdx b/en/develop-plugin/dev-guides-and-walkthroughs/trigger-plugin.mdx index 7662af6d..0f424186 100644 --- a/en/develop-plugin/dev-guides-and-walkthroughs/trigger-plugin.mdx +++ b/en/develop-plugin/dev-guides-and-walkthroughs/trigger-plugin.mdx @@ -83,7 +83,7 @@ To implement subscription creation via manual URL pasting, you need to modify tw Since GitHub webhooks use an encryption mechanism, a secret key is required to decrypt and validate incoming requests. Therefore, you need to declare `webhook_secret` in `github.yaml`. - ```YAML + ```yaml subscription_schema: - name: "webhook_secret" type: "secret-input" @@ -112,7 +112,7 @@ To implement subscription creation via manual URL pasting, you need to modify tw For the complete code sample, see [Dify's GitHub trigger plugin](https://github.com/langgenius/dify-plugin-sdks/tree/feat/trigger/python/examples/github_trigger). - ```Python + ```python class GithubTrigger(Trigger): """Handle GitHub webhook event dispatch.""" @@ -141,7 +141,7 @@ Taking the Issue event as an example, you can define the event and its implement - ```YAML + ```yaml identity: name: issues author: langgenius @@ -167,7 +167,7 @@ Taking the Issue event as an example, you can define the event and its implement ``` - ```Python + ```python from collections.abc import Mapping from typing import Any @@ -205,7 +205,7 @@ To filter out certain events—for example, to focus only on Issue events with a - ```YAML + ```yaml parameters: - name: added_label label: @@ -221,7 +221,7 @@ To filter out certain events—for example, to focus only on Issue events with a ``` - ```Python + ```python def _check_added_label(self, payload: Mapping[str, Any], added_label_param: str | None) -> None: """Check if the added label matches the allowed labels""" if not added_label_param: @@ -256,7 +256,7 @@ To enable automatic subscription creation via OAuth or API key, you need to modi In `github.yaml`, add the following fields. - ```YAML + ```yaml subscription_constructor: parameters: - name: "repository" @@ -307,7 +307,7 @@ To enable automatic subscription creation via OAuth or API key, you need to modi In `github.py`, create a `Constructor` class to implement the automatic subscription logic. - ```Python + ```python class GithubSubscriptionConstructor(TriggerSubscriptionConstructor): """Manage GitHub trigger subscriptions.""" def _validate_api_key(self, credentials: Mapping[str, Any]) -> None: @@ -394,7 +394,7 @@ The interface definitions and implementation methods of core classes in trigger ### Trigger -```Python +```python class Trigger(ABC): @abstractmethod def _dispatch_event(self, subscription: Subscription, request: Request) -> EventDispatch: @@ -431,7 +431,7 @@ class Trigger(ABC): ### TriggerSubscriptionConstructor -```Python +```python class TriggerSubscriptionConstructor(ABC, OAuthProviderProtocol): # OPTIONAL def _validate_api_key(self, credentials: Mapping[str, Any]) -> None: @@ -594,7 +594,7 @@ class TriggerSubscriptionConstructor(ABC, OAuthProviderProtocol): ### Event -```Python +```python class Event(ABC): @abstractmethod def _on_event(self, request: Request, parameters: Mapping[str, Any], payload: Mapping[str, Any]) -> Variables: diff --git a/en/self-host/advanced-deployments/local-source-code.mdx b/en/self-host/advanced-deployments/local-source-code.mdx index 74419aa2..1b716727 100644 --- a/en/self-host/advanced-deployments/local-source-code.mdx +++ b/en/self-host/advanced-deployments/local-source-code.mdx @@ -20,7 +20,7 @@ title: Local Source Code Start ### Clone Dify Repository Run the git command to clone the [Dify repository](https://github.com/langgenius/dify). -```Bash +```bash git clone https://github.com/langgenius/dify.git ``` @@ -28,7 +28,7 @@ git clone https://github.com/langgenius/dify.git A series of middlewares for storage (e.g. PostgreSQL / Redis / Weaviate (if not locally available)) and extended capabilities (e.g. Dify's [sandbox](https://github.com/langgenius/dify-sandbox) and [plugin-daemon](https://github.com/langgenius/dify-plugin-daemon) services) are required by Dify backend services. Start the middlewares with Docker Compose by running these commands: -```Bash +```bash cd docker cp middleware.env.example middleware.env diff --git a/en/self-host/advanced-deployments/start-the-frontend-docker-container.mdx b/en/self-host/advanced-deployments/start-the-frontend-docker-container.mdx index c9336cb0..990c29ba 100644 --- a/en/self-host/advanced-deployments/start-the-frontend-docker-container.mdx +++ b/en/self-host/advanced-deployments/start-the-frontend-docker-container.mdx @@ -6,7 +6,7 @@ When developing the backend separately, you may only need to start the backend s #### Pull the Docker image for the frontend service from DockerHub: -```Bash +```bash docker run -it -p 3000:3000 -e CONSOLE_URL=http://127.0.0.1:5001 -e APP_URL=http://127.0.0.1:5001 langgenius/dify-web:latest ``` diff --git a/en/use-dify/nodes/iteration.mdx b/en/use-dify/nodes/iteration.mdx index 126456d9..0e092398 100644 --- a/en/use-dify/nodes/iteration.mdx +++ b/en/use-dify/nodes/iteration.mdx @@ -131,7 +131,7 @@ Iteration nodes output arrays that often need conversion for final use: - ```jinja2 + ```jinja {{ articleSections | join("\n") }} ``` diff --git a/en/use-dify/nodes/llm.mdx b/en/use-dify/nodes/llm.mdx index 4fe85567..3527abc2 100644 --- a/en/use-dify/nodes/llm.mdx +++ b/en/use-dify/nodes/llm.mdx @@ -112,7 +112,7 @@ The default variable selector for vision is `userinput.files` which automaticall LLM prompts support Jinja2 templating for advanced variable handling. When you use Jinja2 mode (`edition_type: "jinja2"`), you can: -```jinja2 +```jinja {% for item in search_results %} {{ loop.index }}. {{ item.title }}: {{ item.content }} {% endfor %} diff --git a/en/use-dify/nodes/template.mdx b/en/use-dify/nodes/template.mdx index 89a4d6eb..074402c7 100644 --- a/en/use-dify/nodes/template.mdx +++ b/en/use-dify/nodes/template.mdx @@ -18,7 +18,7 @@ Template nodes use Jinja2 templating syntax to create dynamic content that adapt Reference workflow variables using double curly braces: `{{ variable_name }}`. You can access nested object properties and array elements using dot notation and bracket syntax. -```jinja2 +```jinja {{ user.name }} {{ items[0].title }} {{ data.metrics.score }} @@ -28,7 +28,7 @@ Reference workflow variables using double curly braces: `{{ variable_name }}`. Y Show different content based on data values using if-else statements: -```jinja2 +```jinja {% if user.subscription == 'premium' %} Welcome back, Premium Member! You have access to all features. {% else %} @@ -40,7 +40,7 @@ Consider upgrading to Premium for additional capabilities. Process arrays and objects with for loops to generate repetitive content: -```jinja2 +```jinja {% for item in search_results %} ### Result {{ loop.index }} **Score**: {{ item.score | round(2) }} @@ -59,7 +59,7 @@ Process arrays and objects with for loops to generate repetitive content: Jinja2 filters transform data during template rendering: -```jinja2 +```jinja {{ name | upper }} {{ price | round(2) }} {{ content | replace('\n', '
') }} @@ -71,7 +71,7 @@ Jinja2 filters transform data during template rendering: Handle missing or invalid data gracefully using default values and conditional checks: -```jinja2 +```jinja {{ user.email | default('No email provided') }} {{ metrics.accuracy | round(2) if metrics.accuracy else 'Not calculated' }} ``` diff --git a/en/use-dify/nodes/trigger/webhook-trigger.mdx b/en/use-dify/nodes/trigger/webhook-trigger.mdx index 0fdf0d20..2f7dbc52 100644 --- a/en/use-dify/nodes/trigger/webhook-trigger.mdx +++ b/en/use-dify/nodes/trigger/webhook-trigger.mdx @@ -120,7 +120,7 @@ Alternatively, you can send a test request to the webhook trigger and check the - Example: From the following request body, you can extract the `customerName` (`Alex`), the list of items, or the `isPriority` status (`true`). - ```JSON + ```json "customerName": "Alex", "items": [ diff --git a/en/use-dify/workspace/api-extension/api-extension.mdx b/en/use-dify/workspace/api-extension/api-extension.mdx index d20f7cfd..de01f672 100644 --- a/en/use-dify/workspace/api-extension/api-extension.mdx +++ b/en/use-dify/workspace/api-extension/api-extension.mdx @@ -230,7 +230,7 @@ Since the Dify cloud version cannot access internal network API services, you ca ![Download](https://assets-docs.dify.ai/dify-enterprise-mintlify/zh_CN/guides/extension/api-based-extension/c44d6cc5425508daac8d31bc4af113df.png) 2. After downloading, go to the download directory, extract the archive according to the instructions below, and execute the initialization script in the instructions. - ```Shell + ```shell unzip /path/to/ngrok.zip ./ngrok config add-authtoken your-token ``` @@ -240,7 +240,7 @@ Since the Dify cloud version cannot access internal network API services, you ca And run the following command to start: - ```Shell + ```shell ./ngrok http port-number ``` diff --git a/ja/develop-plugin/dev-guides-and-walkthroughs/trigger-plugin.mdx b/ja/develop-plugin/dev-guides-and-walkthroughs/trigger-plugin.mdx index 1ac7e791..c6702cad 100644 --- a/ja/develop-plugin/dev-guides-and-walkthroughs/trigger-plugin.mdx +++ b/ja/develop-plugin/dev-guides-and-walkthroughs/trigger-plugin.mdx @@ -85,7 +85,7 @@ Notion のようなプラットフォームでは、サブスクリプション GitHub の webhook は暗号化メカニズムを使用しているため、受信リクエストを復号化して検証するためにシークレットキーが必要です。そのため、`github.yaml` で `webhook_secret` を宣言する必要があります。 - ```YAML + ```yaml subscription_schema: - name: "webhook_secret" type: "secret-input" @@ -114,7 +114,7 @@ Notion のようなプラットフォームでは、サブスクリプション 完全なコードサンプルについては、[Dify の GitHub トリガープラグイン](https://github.com/langgenius/dify-plugin-sdks/tree/feat/trigger/python/examples/github_trigger)を参照してください。 - ```Python + ```python class GithubTrigger(Trigger): """Handle GitHub webhook event dispatch.""" @@ -143,7 +143,7 @@ Issue イベントを例にとると、`events/issues/issues.yaml` と `events/i - ```YAML + ```yaml identity: name: issues author: langgenius @@ -169,7 +169,7 @@ Issue イベントを例にとると、`events/issues/issues.yaml` と `events/i ``` - ```Python + ```python from collections.abc import Mapping from typing import Any @@ -207,7 +207,7 @@ Issue イベントを例にとると、`events/issues/issues.yaml` と `events/i - ```YAML + ```yaml parameters: - name: added_label label: @@ -223,7 +223,7 @@ Issue イベントを例にとると、`events/issues/issues.yaml` と `events/i ``` - ```Python + ```python def _check_added_label(self, payload: Mapping[str, Any], added_label_param: str | None) -> None: """Check if the added label matches the allowed labels""" if not added_label_param: @@ -258,7 +258,7 @@ OAuth または API キーによる自動サブスクリプション作成を有 `github.yaml` に以下のフィールドを追加します。 - ```YAML + ```yaml subscription_constructor: parameters: - name: "repository" @@ -309,7 +309,7 @@ OAuth または API キーによる自動サブスクリプション作成を有 `github.py` で、自動サブスクリプションロジックを実装する `Constructor` クラスを作成します。 - ```Python + ```python class GithubSubscriptionConstructor(TriggerSubscriptionConstructor): """Manage GitHub trigger subscriptions.""" def _validate_api_key(self, credentials: Mapping[str, Any]) -> None: @@ -396,7 +396,7 @@ OAuth による自動サブスクリプション作成も同じ `Constructor` ### Trigger -```Python +```python class Trigger(ABC): @abstractmethod def _dispatch_event(self, subscription: Subscription, request: Request) -> EventDispatch: @@ -433,7 +433,7 @@ class Trigger(ABC): ### TriggerSubscriptionConstructor -```Python +```python class TriggerSubscriptionConstructor(ABC, OAuthProviderProtocol): # OPTIONAL def _validate_api_key(self, credentials: Mapping[str, Any]) -> None: @@ -596,7 +596,7 @@ class TriggerSubscriptionConstructor(ABC, OAuthProviderProtocol): ### Event -```Python +```python class Event(ABC): @abstractmethod def _on_event(self, request: Request, parameters: Mapping[str, Any], payload: Mapping[str, Any]) -> Variables: diff --git a/ja/self-host/advanced-deployments/local-source-code.mdx b/ja/self-host/advanced-deployments/local-source-code.mdx index 3209e7cb..5e332103 100644 --- a/ja/self-host/advanced-deployments/local-source-code.mdx +++ b/ja/self-host/advanced-deployments/local-source-code.mdx @@ -25,7 +25,7 @@ title: ローカルソースコードからの起動 git コマンドを実行して [Dify リポジトリ](https://github.com/langgenius/dify) をクローンします。 -```Bash +```bash git clone https://github.com/langgenius/dify.git ``` @@ -33,7 +33,7 @@ git clone https://github.com/langgenius/dify.git ストレージ用(PostgreSQL / Redis / Weaviate(ローカルで利用できない場合))や拡張機能用(Dify の [sandbox](https://github.com/langgenius/dify-sandbox) や [plugin-daemon](https://github.com/langgenius/dify-plugin-daemon) サービスなど)の一連のミドルウェアが Dify バックエンドサービスで必要です。次のコマンドを実行して Docker Compose でミドルウェアを起動します: -```Bash +```bash cd docker cp middleware.env.example middleware.env diff --git a/ja/self-host/advanced-deployments/start-the-frontend-docker-container.mdx b/ja/self-host/advanced-deployments/start-the-frontend-docker-container.mdx index 3bf708d6..ecd1656f 100644 --- a/ja/self-host/advanced-deployments/start-the-frontend-docker-container.mdx +++ b/ja/self-host/advanced-deployments/start-the-frontend-docker-container.mdx @@ -8,7 +8,7 @@ title: フロントコンテナ起動 #### DockerHubからフロントエンドサービス用のDockerイメージをプルする: -```Bash +```bash docker run -it -p 3000:3000 -e CONSOLE_URL=http://127.0.0.1:5001 -e APP_URL=http://127.0.0.1:5001 langgenius/dify-web:latest ``` diff --git a/ja/use-dify/nodes/llm.mdx b/ja/use-dify/nodes/llm.mdx index 5b00f589..db070cc4 100644 --- a/ja/use-dify/nodes/llm.mdx +++ b/ja/use-dify/nodes/llm.mdx @@ -114,7 +114,7 @@ User: {{user_input}} LLMプロンプトは高度な変数処理のためにJinja2テンプレートをサポートしています。Jinja2モード(`edition_type: "jinja2"`)を使用すると、次のことができます: -```jinja2 +```jinja {% for item in search_results %} {{ loop.index }}. {{ item.title }}: {{ item.content }} {% endfor %} diff --git a/ja/use-dify/nodes/template.mdx b/ja/use-dify/nodes/template.mdx index 94d0f067..7c3a3ffe 100644 --- a/ja/use-dify/nodes/template.mdx +++ b/ja/use-dify/nodes/template.mdx @@ -21,7 +21,7 @@ icon: "note-sticky" 二重波括弧を使用してワークフロー変数を参照します:`{{ variable_name }}`。ドット記法とブラケット構文を使用して、ネストされたオブジェクトプロパティや配列要素にアクセスできます。 -```jinja2 +```jinja {{ user.name }} {{ items[0].title }} {{ data.metrics.score }} @@ -31,7 +31,7 @@ icon: "note-sticky" if-else文を使用してデータ値に基づいて異なるコンテンツを表示します: -```jinja2 +```jinja {% if user.subscription == 'premium' %} おかえりなさい、プレミアムメンバー様!すべての機能にアクセスできます。 {% else %} @@ -43,7 +43,7 @@ if-else文を使用してデータ値に基づいて異なるコンテンツを for ループを使用して配列とオブジェクトを処理し、反復的なコンテンツを生成します: -```jinja2 +```jinja {% for item in search_results %} ### 結果 {{ loop.index }} **スコア**: {{ item.score | round(2) }} @@ -62,7 +62,7 @@ for ループを使用して配列とオブジェクトを処理し、反復的 Jinja2フィルターはテンプレートレンダリング中にデータを変換します: -```jinja2 +```jinja {{ name | upper }} {{ price | round(2) }} {{ content | replace('\n', '
') }} @@ -74,7 +74,7 @@ Jinja2フィルターはテンプレートレンダリング中にデータを デフォルト値と条件チェックを使用して、欠損または無効なデータを適切に処理します: -```jinja2 +```jinja {{ user.email | default('メールアドレスが提供されていません') }} {{ metrics.accuracy | round(2) if metrics.accuracy else '計算されていません' }} ``` diff --git a/ja/use-dify/nodes/trigger/webhook-trigger.mdx b/ja/use-dify/nodes/trigger/webhook-trigger.mdx index ad84b454..48f3da2b 100644 --- a/ja/use-dify/nodes/trigger/webhook-trigger.mdx +++ b/ja/use-dify/nodes/trigger/webhook-trigger.mdx @@ -122,7 +122,7 @@ Webhook トリガーが受信 HTTP リクエストを処理する方法を定義 - 例:次のリクエストボディから、`customerName`(`Alex`)、アイテムのリスト、または `isPriority` ステータス(`true`)を抽出できます。 - ```JSON + ```json "customerName": "Alex", "items": [ diff --git a/ja/use-dify/workspace/api-extension/api-extension.mdx b/ja/use-dify/workspace/api-extension/api-extension.mdx index 6c7a5bee..d3900b8e 100644 --- a/ja/use-dify/workspace/api-extension/api-extension.mdx +++ b/ja/use-dify/workspace/api-extension/api-extension.mdx @@ -231,7 +231,7 @@ Dify クラウド版では内部ネットワークの API サービスにアク ![Download](https://assets-docs.dify.ai/dify-enterprise-mintlify/zh_CN/guides/extension/api-based-extension/c44d6cc5425508daac8d31bc4af113df.png) 2. ダウンロード完了後、ダウンロードディレクトリに移動し、以下の説明に従って圧縮ファイルを解凍し、説明の初期化スクリプトを実行します。 - ```Shell + ```shell unzip /path/to/ngrok.zip ./ngrok config add-authtoken あなたのToken ``` @@ -241,7 +241,7 @@ Dify クラウド版では内部ネットワークの API サービスにアク そして、以下のコマンドを実行して起動します: - ```Shell + ```shell ./ngrok http ポート番号 ``` diff --git a/zh/develop-plugin/dev-guides-and-walkthroughs/trigger-plugin.mdx b/zh/develop-plugin/dev-guides-and-walkthroughs/trigger-plugin.mdx index cc5f741d..dcc6b621 100644 --- a/zh/develop-plugin/dev-guides-and-walkthroughs/trigger-plugin.mdx +++ b/zh/develop-plugin/dev-guides-and-walkthroughs/trigger-plugin.mdx @@ -85,7 +85,7 @@ Webhook 可以理解为一种基于 HTTP 的事件分发器。**一旦配置了 由于 GitHub webhook 使用加密机制,需要一个密钥来解密和验证传入的请求。因此,你需要在 `github.yaml` 中声明 `webhook_secret`。 - ```YAML + ```yaml subscription_schema: - name: "webhook_secret" type: "secret-input" @@ -114,7 +114,7 @@ Webhook 可以理解为一种基于 HTTP 的事件分发器。**一旦配置了 完整代码示例,请参阅 [Dify 的 GitHub 触发器插件](https://github.com/langgenius/dify-plugin-sdks/tree/feat/trigger/python/examples/github_trigger)。 - ```Python + ```python class GithubTrigger(Trigger): """Handle GitHub webhook event dispatch.""" @@ -143,7 +143,7 @@ Webhook 可以理解为一种基于 HTTP 的事件分发器。**一旦配置了 - ```YAML + ```yaml identity: name: issues author: langgenius @@ -169,7 +169,7 @@ Webhook 可以理解为一种基于 HTTP 的事件分发器。**一旦配置了 ``` - ```Python + ```python from collections.abc import Mapping from typing import Any @@ -207,7 +207,7 @@ Webhook 可以理解为一种基于 HTTP 的事件分发器。**一旦配置了 - ```YAML + ```yaml parameters: - name: added_label label: @@ -223,7 +223,7 @@ Webhook 可以理解为一种基于 HTTP 的事件分发器。**一旦配置了 ``` - ```Python + ```python def _check_added_label(self, payload: Mapping[str, Any], added_label_param: str | None) -> None: """Check if the added label matches the allowed labels""" if not added_label_param: @@ -258,7 +258,7 @@ Webhook 可以理解为一种基于 HTTP 的事件分发器。**一旦配置了 在 `github.yaml` 中,添加以下字段。 - ```YAML + ```yaml subscription_constructor: parameters: - name: "repository" @@ -309,7 +309,7 @@ Webhook 可以理解为一种基于 HTTP 的事件分发器。**一旦配置了 在 `github.py` 中,创建一个 `Constructor` 类来实现自动订阅逻辑。 - ```Python + ```python class GithubSubscriptionConstructor(TriggerSubscriptionConstructor): """Manage GitHub trigger subscriptions.""" def _validate_api_key(self, credentials: Mapping[str, Any]) -> None: @@ -396,7 +396,7 @@ Webhook 可以理解为一种基于 HTTP 的事件分发器。**一旦配置了 ### Trigger -```Python +```python class Trigger(ABC): @abstractmethod def _dispatch_event(self, subscription: Subscription, request: Request) -> EventDispatch: @@ -433,7 +433,7 @@ class Trigger(ABC): ### TriggerSubscriptionConstructor -```Python +```python class TriggerSubscriptionConstructor(ABC, OAuthProviderProtocol): # OPTIONAL def _validate_api_key(self, credentials: Mapping[str, Any]) -> None: @@ -596,7 +596,7 @@ class TriggerSubscriptionConstructor(ABC, OAuthProviderProtocol): ### Event -```Python +```python class Event(ABC): @abstractmethod def _on_event(self, request: Request, parameters: Mapping[str, Any], payload: Mapping[str, Any]) -> Variables: diff --git a/zh/self-host/advanced-deployments/local-source-code.mdx b/zh/self-host/advanced-deployments/local-source-code.mdx index bda0152c..633d9081 100644 --- a/zh/self-host/advanced-deployments/local-source-code.mdx +++ b/zh/self-host/advanced-deployments/local-source-code.mdx @@ -24,7 +24,7 @@ title: 使用源代码本地启动 运行 git 命令克隆 [Dify 仓库](https://github.com/langgenius/dify)。 -```Bash +```bash git clone https://github.com/langgenius/dify.git ``` @@ -32,7 +32,7 @@ git clone https://github.com/langgenius/dify.git Dify 后端服务需要一系列用于存储(如 PostgreSQL / Redis / Weaviate(如果本地不可用))和扩展能力(如 Dify 的 [sandbox](https://github.com/langgenius/dify-sandbox) 和 [plugin-daemon](https://github.com/langgenius/dify-plugin-daemon) 服务)的中间件。通过运行以下命令使用 Docker Compose 启动中间件: -```Bash +```bash cd docker cp middleware.env.example middleware.env diff --git a/zh/self-host/advanced-deployments/start-the-frontend-docker-container.mdx b/zh/self-host/advanced-deployments/start-the-frontend-docker-container.mdx index 7d33f8b8..4b0313b1 100644 --- a/zh/self-host/advanced-deployments/start-the-frontend-docker-container.mdx +++ b/zh/self-host/advanced-deployments/start-the-frontend-docker-container.mdx @@ -8,7 +8,7 @@ title: 单独启动前端 Docker 容器 #### 从 DockerHub 拉取前端服务的 Docker 镜像: -```Bash +```bash docker run -it -p 3000:3000 -e CONSOLE_URL=http://127.0.0.1:5001 -e APP_URL=http://127.0.0.1:5001 langgenius/dify-web:latest ``` diff --git a/zh/use-dify/nodes/llm.mdx b/zh/use-dify/nodes/llm.mdx index 6c76e1ce..ab915e53 100644 --- a/zh/use-dify/nodes/llm.mdx +++ b/zh/use-dify/nodes/llm.mdx @@ -114,7 +114,7 @@ Question: {{user_question}} 大型语言模型提示词支持 Jinja2 模板以进行高级变量处理。当你使用 Jinja2 模式(`edition_type: "jinja2"`)时,你可以: -```jinja2 +```jinja {% for item in search_results %} {{ loop.index }}. {{ item.title }}: {{ item.content }} {% endfor %} diff --git a/zh/use-dify/nodes/template.mdx b/zh/use-dify/nodes/template.mdx index 77af5022..39180097 100644 --- a/zh/use-dify/nodes/template.mdx +++ b/zh/use-dify/nodes/template.mdx @@ -20,7 +20,7 @@ icon: "note-sticky" 使用双花括号引用工作流变量:`{{ variable_name }}`。你可以使用点号和括号语法访问嵌套对象属性和数组元素。 -```jinja2 +```jinja {{ user.name }} {{ items[0].title }} {{ data.metrics.score }} @@ -30,7 +30,7 @@ icon: "note-sticky" 使用 if-else 语句根据数据值显示不同内容: -```jinja2 +```jinja {% if user.subscription == 'premium' %} 欢迎回来,高级会员!你可以访问所有功能。 {% else %} @@ -42,7 +42,7 @@ icon: "note-sticky" 使用 for 循环处理数组和对象以生成重复内容: -```jinja2 +```jinja {% for item in search_results %} ### 结果 {{ loop.index }} **分数**: {{ item.score | round(2) }} @@ -61,7 +61,7 @@ icon: "note-sticky" Jinja2 过滤器在模板渲染期间转换数据: -```jinja2 +```jinja {{ name | upper }} {{ price | round(2) }} {{ content | replace('\n', '
') }} @@ -73,7 +73,7 @@ Jinja2 过滤器在模板渲染期间转换数据: 使用默认值和条件检查优雅地处理缺失或无效数据: -```jinja2 +```jinja {{ user.email | default('未提供邮箱') }} {{ metrics.accuracy | round(2) if metrics.accuracy else '未计算' }} ``` diff --git a/zh/use-dify/nodes/trigger/webhook-trigger.mdx b/zh/use-dify/nodes/trigger/webhook-trigger.mdx index 2c43d39e..094924d4 100644 --- a/zh/use-dify/nodes/trigger/webhook-trigger.mdx +++ b/zh/use-dify/nodes/trigger/webhook-trigger.mdx @@ -116,7 +116,7 @@ Webhook 允许一个系统自动向另一个系统发送实时数据。当某个 - 示例:从以下请求体中,可提取 `customerName`(`Alex`)、`items` 列表或 `isPriority` 状态(`true`)。 - ```JSON + ```json "customerName": "Alex", "items": [ diff --git a/zh/use-dify/workspace/api-extension/api-extension.mdx b/zh/use-dify/workspace/api-extension/api-extension.mdx index 22e54d7b..b1c8663c 100644 --- a/zh/use-dify/workspace/api-extension/api-extension.mdx +++ b/zh/use-dify/workspace/api-extension/api-extension.mdx @@ -230,7 +230,7 @@ API 返回为: ![Download](https://assets-docs.dify.ai/dify-enterprise-mintlify/zh_CN/guides/extension/api-based-extension/c44d6cc5425508daac8d31bc4af113df.png) 2. 下载完成后,进入下载目录,根据下方说明解压压缩包,并执行说明中的初始化脚本。 - ```Shell + ```shell unzip /path/to/ngrok.zip ./ngrok config add-authtoken 你的Token ``` @@ -240,7 +240,7 @@ API 返回为: 并运行以下命令启动: - ```Shell + ```shell ./ngrok http 端口号 ```