---
title: "スクリバンテンプレート"
slug: "scriban-templates"
abstract: "Scribanテンプレートの概要とその使い方。"
---
# スクリバンテンプレート

スクリバンテンプレートはSXAレンダリングバリアントに保存され、追加のレンダラーとして利用可能です。例えば、フィールドレンダラー、セクション、タグなどです。スクリバンテンプレートは他のレンダラーと共存できますが、既存のレンダリングバリアントを置き換えるためにも利用できます。

![How to access the Scriban command from the content tree.](https://doc.sitecore.com/api/markdown-image/xp/ja/developers/sxa/93/sitecore-experience-accelerator/images/SXA-Scriban.png)

> !重要SXAコンポーネントのレンダリングバリアントとしてScribanテンプレートを使用したい場合は、壊れたスタイルを避けるために、Scribanテンプレートと適用されたテーマ内のすべてのHTML子要素を手動でスタイル化する必要があります。

Creative Exchangeを使ってScribanテンプレートのエクスポートおよびインポートが可能です。これにより、フロントエンド開発者はコンポーネントのマークアップや機能に対してはるかに柔軟性があります。Scribanテンプレートは、単純なトークンのレンダリングからコンポーネントの完全代替機能まで様々です。例えば、以下のレンダリングバリアントはGalleryコンポーネントのコンテンツをレンダリングしています:

{{-
 if i\_item.template\_name == "Gallery Image"
 sc\_editframe i\_item 'Gallery Image' -}}
 <a class="field-image">
 <a title="{{ i\_item.ImageTitle.raw }}" href="https://doc.sitecore.com/xp/ja/developers/sxa/93/sitecore-experience-accelerator/%7B%7B%20i/_item.Image.media/_url%20%7D%7D">
 {{ i\_item.Image }}
 </a>
 </a>{{
 sc\_endeditframe
 end -}}

{{-
 if i\_item.template\_name == "Gallery Video"
 sc\_editframe i\_item 'Gallery Video'
 if (i\_item.VideoID.raw ) == "" &&(i\_item.VideoThumbnail.raw) == "" -}}
 <span>Edit Gallery Video here</span>{{
 else -}}
 <a title="{{i\_item.VideoTitle.raw }}" href="http://www.youtube.com/watch?v={{ i\_item.VideoID.raw }}">
 <img src="https://doc.sitecore.com/api/markdown-image/xp/ja/developers/sxa/93/sitecore-experience-accelerator/%7B%7B%20o/_model.thumbnail/_url%20%7D%7D" alt="{{ i\_item.VideoDescription.raw }}"
 data-title="{{ i\_item.VideoTitle.raw }}" data-description="{{ i\_item.VideoDescription.raw }}" ></img>
 </a>{{
 end
 sc\_endeditframe
 end }}

この例は、アイテムテンプレートに基づいてHTMLコードの一部を条件付けてレンダリングする方法、レンダリングC#モデルへのアクセス方法、プロパティおよびアイテムプロパティの呼び出方法を示しています。また、編集体験を向上させるためにコンポーネントの領域を*Edit frames*でラップします。

このセクションのトピックは、ScribanテンプレートのSitecore拡張機能について説明します。

-   [組み込み関数](https://doc.sitecore.com/xp/ja/developers/sxa/93/sitecore-experience-accelerator/the-embedded-functions-for-the-scriban-template.html "The embedded functions for the Scriban template")
-   [埋め込みオブジェクトとアイテム](https://doc.sitecore.com/xp/ja/developers/sxa/93/sitecore-experience-accelerator/the-embedded-items-and-objects-in-the-scriban-context.html "The embedded items and objects in the Scriban context")
-   [アイテムおよびフィールド拡張](https://doc.sitecore.com/xp/ja/developers/sxa/93/sitecore-experience-accelerator/item-and-field-extensions.html "Item and field extensions")

> !注基盤となる [テンプレート言語](https://github.com/lunet-io/scriban/blob/master/doc/language.md) や [組み込み関数](https://github.com/lunet-io/scriban/blob/master/doc/builtins.md) については、[ScribanのGitHubリポジトリ](https://github.com/lunet-io/scriban)に一般的なドキュメントが掲載されています。

Discover Sitecoreチャンネルのこの動画で、Scribanの使い方のデモンストレーションを見ることができます。

:::youtube{id="TcWXVrzhuTE"}