Skip to main content
Sitecore Documentation
  • Learn
  • Downloads
  • Changelog
  • Roadmap
PersonalizeCloud Portal
Sitecore Personalize developer documentation
  • 開発Sitecore Personalize
    • ベースURL
    • レスポンスコード
        • テンプレートを作成する
        • テンプレートの取得
        • テンプレートの取得
        • テンプレートを更新する
        • テンプレートのリビジョンを取得する
        • テンプレートのリビジョンを取得する
        • プレビュー テンプレート
        • テンプレート コードのプレビュー
  1. テンプレートREST API
  1. REST API
  2. テンプレートREST API
  3. テンプレート コードのプレビュー

テンプレート コードのプレビュー

日本語翻訳に関する免責事項

このページの翻訳はAIによって自動的に行われました。可能な限り正確な翻訳を心掛けていますが、原文と異なる表現や解釈が含まれる場合があります。正確で公式な情報については、必ず英語の原文をご参照ください。

POST /v3/templates/process

このエンドポイントを使用すると、テンプレート パラメーターを含む テンプレート コードを テストできます。テンプレートパラメータは、テンプレートのレンダリング時にテンプレート変数値に置き換えられる動的なプレースホルダです。

リクエストには、テンプレートパラメータとテンプレート変数値の両方を含めます。応答では、テンプレート変数の値を含むテンプレート コード全体が返されます。

少なくとも、要求本文で次の必須属性を指定する必要があります。

属性

種類

形容

使用例

templates

JSONオブジェクトのJSON配列

テンプレートを定義するカスタムHTML、CSS、JavaScript、FreeMarkerコード。

該当なし

templateVariables

オブジェクト

テンプレート変数とそれに対応する値。

{ "Name": "John", "ProductType": "sneakers" }

オブジェクトのtemplates配列内のオブジェクトには、次の属性を使用します。

属性

種類

形容

使用例

id

string enum (小文字)

template属性に含めるコードの種類。

例えば、テンプレートにCSSコードを含めるには、この値を "css"に設定し、template属性でカスタムCSSコードを指定します。

次のいずれかである必要があります。

  • "html"

  • "css"

  • "js"

  • "freemarker"

template

糸

文字列化されたHTML、CSS、JavaScript、またはFreeMarkerコード。

FreeMarkerコードの場合は、少なくとも 開始中括弧と終了中括弧 {}を含める必要があります。

  • HTMLの: "<div id=\"test\">Our best ProductType | string on sale</div>"

  • CSSの: "#test {text-transform: uppercase}"

  • JavaScriptの: "insertHTMLBefore(\"body\");"

  • フリーマーカー: "{}"

リクエストには、テンプレートパラメータ(ProductType | stringなど)とテンプレート変数値(ProductTypeのsneakersなど)を含めます。

curl -X POST '<baseURL>/v3/templates/process' \
-H 'Authorization: Bearer <accessToken>' \
-H 'Accept: application/json' \
--data-raw '
{
  "templates": [
    {
      "id": "html",
      "template": "<title>Hi, [[Name | string]]!</title>\n<content>This week, our [[ProductType | string]] are on sale!<content>"
    },
    {
        "id": "css",
        "template": "title {text-transform: [[Style | string]]}"
    }
  ],
  "templateVariables": {
    "Name": "John",
    "ProductType": "sneakers",
    "Style": "uppercase"
  }
}'

応答では、テンプレート変数の値 ( 、John、sneakers、uppercaseなど) を含むテンプレートコード全体が返されます。

{
    "templates": [
        {
            "id": "html",
            "template": "<title>Hi, John!</title>\n<content>This week, our sneakers are on sale!<content>"
        },
        {
            "id": "css",
            "template": "title {text-transform: uppercase}"
        }
    ]
}
この記事を改善するための提案がある場合は、 お知らせください!

Documentation Assistant

This assistant uses AI to generate responses based on Sitecore documentation. While it has access to official sources, answers may be incomplete or inaccurate and should not be considered official advice or support.
Powered by
k
kapa.ai
Protected by reCAPTCHA

© Copyright 2026, Sitecore A/S or a Sitecore affiliated company.
All rights reserved.

Privacy policySitecore Trust CenterTerms of use