テンプレートのコンパイル

テンプレートをコンパイルすると、テンプレート内のサイトのstructure.jsonファイルにある各ページの静的HTMLページが作成されます。

コンパイル・ステップではページ・メタデータ(たとえば、100.json)をページ・レイアウト(たとえば、about.html)を結合するため、HTMLページが即座に表示され、実行時にコントローラの必要がありません。カスタム・コンパイラを使用すると、すでにナビゲーションおよびコンポーネントなどの動的アイテムがページに事前にコンパイルされているため、ランタイムJavaScript実行を減らすことができます。

cec compile-templateコマンドは、サイトの各ページに対して次のアクションを実行します。

  • サイトおよびページのメタデータを読み取ります
  • ページ・レイアウトを読み取り、ページ・レイアウト・コンパイラを適用します
  • ページの各スロットに対して次を行います:
    • page.jsonファイルで定義されたグリッドでスロットを拡張します
    • スロット内の各コンポーネントに対して次を行います:
      • コンポーネント・コンパイラを適用します
      • 生成したコンポーネントのマークアップをスロット内の対応する場所に挿入します
  • コンパイル済マークアップでマクロを拡張し、実行時にOracle Content Managementレンダラで使用されるSCS JavaScriptオブジェクトを挿入します
  • コンパイル済ページ・マークアップをsrc/templates/<template>/staticフォルダに保存します

サイトをコンパイルするには、次を実行します:

> cec compile-template BlogTemplate
Compile Template: compiling template BlogTemplate
Oracle Content Management Site Compiler

createPage: Processing pageId 100. Preview URL: 
http://localhost:8085/templates/BlogTemplate/index.html 
createPage: Processing pageId 105. Preview URL: 
http://localhost:8085/templates/BlogTemplate/post-detail.html 
createPage: Processing pageId 401. Preview URL: 
http://localhost:8085/templates/BlogTemplate/about.html 
createPage: Processing pageId 402. Preview URL: 
http://localhost:8085/templates/BlogTemplate/search.html 
createPage: Processing pageId 403. Preview URL: 
http://localhost:8085/templates/BlogTemplate/authors.html 
All page creation calls complete.

Creating detail pages: 
createPage: Processing detail pageId 105. Preview URL: 
http://localhost:8085/templates/BlogTemplate/post-detail/1481786063051-developing-content-layout- for-content-and-experience-cloud
createPage: Processing detail pageId 105. Preview URL: 
http://localhost:8085/templates/BlogTemplate/post-detail/1481786063052-dynamic-dom- manipulation-in-content-layout 
createPage: Processing detail pageId 105. Preview URL: 
http://localhost:8085/templates/BlogTemplate/post-detail/1481786063045-getting-media-url-in- the-content-layout 
createPage: Processing detail pageId 105. Preview URL: 
http://localhost:8085/templates/BlogTemplate/post-detail/1481786063053-getting-reference- items-in-content-layout 
createPage: Processing detail pageId 105. Preview URL: 
http://localhost:8085/templates/BlogTemplate/post-detail/1481786063048-navigating-to-a- search-page-with-search-query 
createPage: Processing detail pageId 105. Preview URL: 
http://localhost:8085/templates/BlogTemplate/post-detail/1481786063050-alex-read 
createPage: Processing detail pageId 105. Preview URL: 
http://localhost:8085/templates/BlogTemplate/post-detail/1481786063047-jerrold-summers 
createPage: Processing detail pageId 105. Preview URL: 
http://localhost:8085/templates/BlogTemplate/post-detail/1481786063049-kelly-emerson 
createPage: Processing detail pageId 105. Preview URL: 
http://localhost:8085/templates/BlogTemplate/post-detail/1481786063043-samantha-howard 
createPage: Processing detail pageId 105. Preview URL: 
http://localhost:8085/templates/BlogTemplate/post-detail/1481786063046-raising-triggers-from- content-layout 
createPage: Processing detail pageId 105. Preview URL: 
http://localhost:8085/templates/BlogTemplate/post-detail/1481786063044-rendering-the-content- layout-using-mustache-template 
All detail page creation calls complete.

コンパイル・エラー

コンパイル時に、3つのタイプのメッセージ(情報、警告、エラー)が表示されます。

  1. 情報メッセージは認識する必要がある問題に関するものですが、これらのメッセージはコンパイルの一環としてみなされます。
    • プレースホルダ・コンテンツ・アイテムであり、実行時にレンダリングされます。
    • ページ・レイアウト・コンパイラがありません。ページ・レイアウトに動的要素がない可能性があります。そのため、動的要素がない場合は問題とみなされません。
    • "アクセス時にレンダリング"としてマークされたアイテム。すなわち、ページをコンパイルしたときでも、サイト開発者はこのコンポーネントを実行時に動的にレンダリングする必要があります。
  2. 警告メッセージは実行しているサイトのパフォーマンスに影響を及ぼす可能性がある問題に関するもので、可能であれば修正する必要があります。このカテゴリのアイテムは次のとおりです。
    • コンテンツ・アイテムまたはカスタム・コンポーネント・コンパイラがありません。これらがなくても、コンポーネントは以前と同様に動的にページにレンダリングされます。
    • コンテンツ・レイアウト・マップがありません。システムのデフォルト・コンテンツ・レイアウトを使用したコンテンツ・アイテムのレンダリングが必要になる可能性は低くなります。
  3. エラー・メッセージは、コンパイルの失敗を示す問題に関するものです。ページは可能であればコンパイルを続行しますが、全体のコンパイルはエラーで終了します。
    • これは、カスタム・コンパイラのJavaScriptエラーのために起きる可能性が高く、エラーは解決する必要があります。

注:

繰返しメッセージを減らすために、同じメッセージは、複数ページで発生するかどうかに関係なく、コンパイルごとに1回のみ表示されます。

前述の例は、次のコンパイル終了ステータスになります。

Compilation completed with 0 errors and 3 warnings. 
to display warnings, run with --verbose (-v) option.

"-v"オプションでコンパイル・ステップを再実行する場合、次のような出力が表示されます。

> cec compile-template BlogTemplate --verbose
Compile Template: compiling template BlogTemplate 
Oracle Content Management Site Compiler

createPage: Processing pageId 100. Preview URL: 
http://localhost:8085/templates/BlogTemplate/index.html 
createPage: Processing pageId 105. Preview URL: 
http://localhost:8085/templates/BlogTemplate/post-detail.html
Info: no content item specified for placeholder: a890a65c-c0fc-451b-966b-e606ca18a1f4 
component will render at runtime. 
Info: no content item specified for placeholder: c90bbc10-c9d8-4a54-8dd4-7a8251e8efbb 
component will render at runtime. 
Info: no content item specified for placeholder: f12691e1-79ab-4d1f-a8b9-3af8c638dd26 
component will render at runtime.
createPage: Processing pageId 401. Preview URL: 
http://localhost:8085/templates/BlogTemplate/about.html 
createPage: Processing pageId 402. Preview URL: 
http://localhost:8085/templates/BlogTemplate/search.html
Info: Component: "fdfd0392-e901-48f6-8044-36803c836aa1" of type "scs-contentlist" marked as 
"render on access", will not be compiled. 
Info: Component: "ba9f3711-4367-444e-ae38-71289fc10e73" of type "scs-contentlist" marked as 
"render on access", will not be compiled. 
createPage: Processing pageId 403. Preview URL: 
http://localhost:8085/templates/BlogTemplate/authors.html 
All page creation calls complete. 

Creating detail pages: 
createPage: Processing detail pageId 105. Preview URL: 
http://localhost:8085/templates/BlogTemplate/post-detail/1481786063051-developing-content- layout-for-content-and-experience-cloud 
createPage: Processing detail pageId 105. Preview URL: 
http://localhost:8085/templates/BlogTemplate/post-detail/1481786063052-dynamic-dom- manipulation-in-content-layout 
createPage: Processing detail pageId 105. Preview URL: 
http://localhost:8085/templates/BlogTemplate/post-detail/1481786063045-getting-media-url-in- the-content-layout 
createPage: Processing detail pageId 105. Preview URL: 
http://localhost:8085/templates/BlogTemplate/post-detail/1481786063053-getting-reference- items-in-content-layout 
createPage: Processing detail pageId 105. Preview URL: 
http://localhost:8085/templates/BlogTemplate/post-detail/1481786063048-navigating-to-a- search-page-with-search-query 
createPage: Processing detail pageId 105. Preview URL: 
http://localhost:8085/templates/BlogTemplate/post-detail/1481786063050-alex-read 
Warning: failed to find content layout map entry for: Starter-Blog-Author:header. Will compile 
using the system default layout.
Warning: failed to find content layout map entry for: Starter-Blog-Author:content. Will compile 
using the system default layout. 
Warning: failed to find content layout map entry for: Starter-Blog-Author:sidebar. Will compile 
using the system default layout.  
createPage: Processing detail pageId 105. Preview URL: 
http://localhost:8085/templates/BlogTemplate/post-detail/1481786063047-jerrold-summers 
createPage: Processing detail pageId 105. Preview URL: 
http://localhost:8085/templates/BlogTemplate/post-detail/1481786063049-kelly-emerson 
createPage: Processing detail pageId 105. Preview URL: 
http://localhost:8085/templates/BlogTemplate/post-detail/1481786063043-samantha-howard 
createPage: Processing detail pageId 105. 
Preview URL: http://localhost:8085/templates/BlogTemplate/post-detail/1481786063046-raising-triggers-from- content-layout 
createPage: Processing detail pageId 105. Preview URL: 
http://localhost:8085/templates/BlogTemplate/post-detail/1481786063044-rendering-the-content- layout-using-mustache-template 
All detail page creation calls complete. 

Compilation completed with 0 errors and 3 warnings. 

*** compiled template is ready to test 
*** to render non-compiled pages, remove compiled files from under: /private/tmp/cec-
src/src/templates/BlogTemplate/static

詳細ページのコンパイル

詳細ページのコンパイルでは、コンパイル時に見つかったすべてのコンテンツ・アイテムが照合されます。その後、スラグ値を使用して新しい詳細ページのURLを定義して、見つかったコンテンツ・アイテムごとに詳細ページを再コンパイルします。

前述のコンパイルでは、次の2つのセクションで出力があります。

  1. ページのコンパイル
  2. 詳細ページのコンパイル

前述の例では、Starter-Blog-Authorページにコンテンツ・レイアウト・マップ・エントリがないことに関して警告が表示されます。ただし、Starter-Blog-Authorの詳細ページは不要です。詳細ページは、Starter-Blog-Postコンテンツ・アイテム専用です。これらのエラーを削除するには、設定で参照される明示的な詳細ページがない場合、次のオプションを指定して、詳細ページのコンパイルからコンテンツ・アイテムを除外します。

--noDefaultDetailPageLink, -o  Do not generate compiled detail page for items/content lists
      that use the default detail page.

したがって、コンパイルを再実行し、デフォルトの詳細ページを使用する詳細ページの作成を除外すると、次のように出力されます。

> cec compile-template BlogTemplate --noDefaultDetailPageLink 
Compile Template: compiling template BlogTemplate 
Oracle Content Management Site Compiler 

createPage: Processing pageId 100. Preview URL: 
http://localhost:8085/templates/BlogTemplate/index.html 
createPage: Processing pageId 105. Preview URL: 
http://localhost:8085/templates/BlogTemplate/post-detail.html 
createPage: Processing pageId 401. Preview URL: 
http://localhost:8085/templates/BlogTemplate/about.html 
createPage: Processing pageId 402. Preview URL: 
http://localhost:8085/templates/BlogTemplate/search.html 
createPage: Processing pageId 403. Preview URL: 
http://localhost:8085/templates/BlogTemplate/authors.html 
All page creation calls complete.

Creating detail pages: 
createPage: Processing detail pageId 105. Preview URL: 
http://localhost:8085/templates/BlogTemplate/post-detail/1481786063051-developing-content-
layout-for-content-and-experience-cloud
createPage: Processing detail pageId 105. Preview URL:
http://localhost:8085/templates/BlogTemplate/post-detail/1481786063052-dynamic-dom -manipulation-in-content-layout
createPage: Processing detail pageId 105. Preview URL: 
http://localhost:8085/templates/BlogTemplate/post-detail/1481786063045-getting-media-url-in- the-content-layout
createPage: Processing detail pageId 105. Preview URL:  
http://localhost:8085/templates/BlogTemplate/post-detail/1481786063053-getting-reference- items-in-content-layout
createPage: Processing detail pageId 105. Preview URL: 
http://localhost:8085/templates/BlogTemplate/post-detail/1481786063048-navigating-to-a- search-page-with-search-query
All detail page creation calls complete.

Compilation completed with no errors.

*** compiled template is ready to test 
*** to render non-compiled pages, remove compiled files from under: /private/tmp/cec-
src/src/templates/BlogTemplate/static

特定のページのコンパイル

テンプレートのすべてのページをコンパイルする必要はありません。コンパイルするページを選択できます。これは、サイト全体を継続的に再コンパイルするのではなく、デバッグまたは更新する特定のページで作業する場合に便利です。

特定のページをコンパイルするには、--pages (-p)オプションを使用し、その後にコンパイルするページのリストを指定します。

注:

ノート: コンテンツ・アイテムがリスト参照詳細ページ内のページにある場合、詳細ページが明示的に含まれない場合でも、これらはコンパイルされます。

cec compile-template BlogTemplate --pages 401,402 
Compile Template: compiling template BlogTemplate 
Oracle Content Management Site Compiler

createPage: Processing pageId 401. Preview URL: 
http://localhost:8085/templates/BlogTemplate/about.html 
createPage: Processing pageId 402. Preview URL: 
http://localhost:8085/templates/BlogTemplate/search.html 
All page creation calls complete.

Compilation completed with no errors. 
*** compiled template is ready to test 
*** to render non-compiled pages, remove compiled files from under: /private/tmp/cec- 
src/src/templates/BlogTemplate/static