利用できるリソースプラグイン

ここではZend_Applicationにおいて既定で利用可能なリソースプラグインの すべてについて、APIのようにドキュメントをご覧いただけます。

Zend_Application_Resource_Cachemanager

Zend_Application_Resource_Cachemanager may be utilised to configure a set of Zend_Cache option bundles for use when lazy loading caches using Zend_Cache_Manager

As the Cache Manager is a lazy loading mechanism, the options are translated to option templates used to instantiate a cache object on request.

例31 Sample Cachemanager resource configuration

Below is a sample INI file showing how Zend_Cache_Manager may be configured. The format is the Cachemanager resource prefix (resources.cachemanager) followed be the name to assign to an option cache template or bundle (e.g. resources.cachemanager.database) and finally followed by a typical Zend_Cache option.

resources.cachemanager.database.frontend.name = Core
resources.cachemanager.database.frontend.customFrontendNaming = false
resources.cachemanager.database.frontend.options.lifetime = 7200
resources.cachemanager.database.frontend.options.automatic_serialization = true
resources.cachemanager.database.backend.name = File
resources.cachemanager.database.backend.customBackendNaming = false
resources.cachemanager.database.backend.options.cache_dir = "/path/to/cache"
resources.cachemanager.database.frontendBackendAutoload = false

Actually retrieving this cache from the Cache Manager is as simple as accessing an instance of the Manager (Zend_Cache_Manager) retrieved from Zend_Application_Resource_Cachemanager and calling Zend_Cache_Manager::getCache('database'). The example below is taken from a controller where the bootstrap class can be accessed as a Front Controller parameter (which is automatically assigned during bootstrapping). As you can see, the Cache Manager Resource implements a getCacheManager() method to retrieve the bootstrapped instance of Zend_Cache_Manager.

$manager = $this->getFrontController()
            ->getParam('bootstrap')
            ->getPluginResource('cachemanager')
            ->getCacheManager();
$dbCache = $manager->getCache('database');

See Zend_Cache::factory() method to get a description of the default values you can assign when configuring a cache via a configuration file such as out example INI file above.


Zend_Application_Resource_Db(日本語)

Zend_Application_Resource_Dbは、 それに渡されるオプションに基づいてZend_Dbアダプタを初期化します。 デフォルトで、Zend_Db_Table用のデフォルト・アダプタとして、 アダプタを設定します。 複数のデータベースを同時に利用したい場合、 Multidb リソース・プラグイン を利用できます。

以下の構成キーが認識されます:

  • adapter: Zend_Dbアダプタ・タイプ

  • params: アダプタ・インスタンスを取得するときに使う構成パラメータの連想配列です。

  • isDefaultTableAdapter: アダプタをデフォルト・テーブル・アダプタとして確立するべきかどうか。

  • defaultMetadataCache: Zend_Db_Table 用にメタデータ・キャッシュとして使用する キャッシュ・テンプレートまたは Zend_Cache_Core のインスタンスの名前。

例32 DBアダプタ・リソース構成サンプル

下記は、DBリソースを初期化するために使えるINI構成サンプルです。

[production]
resources.db.adapter = "pdo_mysql"
resources.db.params.host = "localhost"
resources.db.params.username = "webuser"
resources.db.params.password = "XXXXXXX"
resources.db.params.dbname = "test"
resources.db.isDefaultTableAdapter = true

; メタデータ・キャッシュ用に使用するキャッシュ・テンプレートも任意に(訳注:動詞不明)できます。
resources.db.defaultMetadataCache = "database"

アダプタのインスタンスを取得する

このリソースでインスタンス化されるアダプタを デフォルト・テーブル・アダプタにしないことを選ぶなら、 あなたはどうやってアダプタ・インスタンスを取得しますか?

どんなリソース・プラグインでも、 ブートストラップからDBリソース・プラグインを取ってくることができます:

$resource = $bootstrap->getPluginResource('db');

一旦リソースオブジェクトを所有するなら、 getDbAdapter()メソッドを用いてDBアダプタを取ってくることができます:

$db = $resource->getDbAdapter();

Zend_Application_Resource_Dojo(日本語)

Zend_Application_Resource_Dojoは、 Zend_Dojo viewhelper を設定するために使用できます。

例33 Dojo リソース設定例

下記は、Zend_Dojo を利用可能にする方法を示す、 INI ファイル例です。

resources.dojo.enable = true ; Always load the Dojo javascript files

The Zend_Dojo resource plugin utilises the options for the Zend_Dojo_View_Helper_Dojo_Container::setOptions() to configure the viewhelpers. Please see the Zend_Dojo chapter for full descriptions and available options.


Zend_Application_Resource_Frontcontroller(日本語)

おそらく、あなたがZend_Applicationでロードする 最も一般的なリソースはフロントコントローラ・リソースです。 そして、それはZend_Controller_Frontを構成する能力を提供します。 このリソースは、 任意のフロントコントローラ・パラメータを設定したり、初期化するプラグインを指定したり、 そのほかにも能力を提供します。

一旦初期化されると、 リソースはブートストラップの$frontControllerプロパティを Zend_Controller_Frontインスタンスに割り当てます。

利用できる構成キーは以下を含みます。大文字と小文字の区別をしません:

  • controllerDirectory: コントローラ・ディレクトリを単独で指定している文字列値か、 またはモジュールからコントローラ・ディレクトリへの連想配列。

  • moduleControllerDirectoryName: コントローラを含むモジュールの配下でサブディレクトリを示す文字列値

  • moduleDirectory: モジュールが見つかるかもしれないディレクトリ

  • defaultControllerName: デフォルト・コントローラの基底名。(通常は "index")

  • defaultAction: デフォルト・アクションの基底名。(通常は "index")

  • defaultModule: デフォルト・モジュールの基底名。(通常は "default")

  • baseUrl: アプリケーションに対して明示された基底URL (通常は自動検出)

  • plugins: フロントコントローラのプラグイン・クラス名配列 このリソースは、各々のクラスを(コンストラクタ引数なしで)インスタンス化して、 それからフロントコントローラでインスタンスを登録します。 独自のスタック・インデックスでプラグインを登録したい場合は、 2つのキー class および stackIndex を持つ配列を与える必要があります。

  • params: フロントコントローラに登録する連想配列

  • returnresponse: フロント・コントローラをディスパッチした後にレスポンス・オブジェクトを返すべきかどうか。 値は、ブーリアンでなければなりません。デフォルトで、これは無効です。

  • dispatcher: allows overriding the default dispatcher. Has two subkeys, class (the classname of new dispatcher) and params, an array of parameters to pass to the dispatcher constructor.

    例34 ディスパッチャーを上書き

    [production]
    resources.frontController.dispatcher.class = "My_Custom_Dispatcher"
    resources.frontController.dispatcher.params.foo = "bar"
    resources.frontController.dispatcher.params.baz = "grok"
    

認識されていないキーが与えられると、 setParam()に渡すことで、 フロントコントローラ・パラメータとして登録されます。

例35 フロントコントローラ・リソース構成サンプル

下記は、フロントコントローラ・リソースを設定する方法を示すINIスニペット・サンプルです。

[production]
resources.frontController.controllerDirectory = APPLICATION_PATH "/controllers"
resources.frontController.moduleControllerDirectoryName = "actions"
resources.frontController.moduleDirectory = APPLICATION_PATH "/modules"
resources.frontController.defaultControllerName = "site"
resources.frontController.defaultAction = "home"
resources.frontController.defaultModule = "static"
resources.frontController.baseUrl = "/subdir"
resources.frontController.plugins.foo = "My_Plugin_Foo"
resources.frontController.plugins.bar = "My_Plugin_Bar"
resources.frontController.plugins.baz.class = "My_Plugin_Baz"
resources.frontController.plugins.baz.stackIndex = 123
resources.frontController.returnresponse = 1
resources.frontController.env = APPLICATION_ENV

; 下記の代用です:
;Zend_Controller_Action_HelperBroker::addPath('Helper_Path', $helperPrefix);
resources.frontController.actionHelperPaths.HELPER_Prefix = "My/Helper/Path"

例36 ブートストラップでフロントコントローラを取得

一旦フロントコントローラ・リソースが初期化されたら、 ブートストラップの$frontControllerプロパティを通じて フロントコントローラ・インスタンスを取ってくることができます。

$bootstrap->bootstrap('frontController');
$front = $bootstrap->frontController;

Zend_Application_Resource_Layout(日本語)

Zend_Application_Resource_Layoutは、 Zend_Layoutを構成するために使用できます。 構成オプションは、Zend_Layout オプション毎にあります。

例37 レイアウト構成サンプル

下記は、レイアウト・リソースを設定する方法を示す、 INIスニペット・サンプルです。

resources.layout.layout = "NameOfDefaultLayout"
resources.layout.layoutPath = "/path/to/layouts"

Zend_Application_Resource_Locale

Zend_Application_Resource_Locale can be used to set an application-wide locale which is then used in all classes and components which work with localization or internationalization. By default the locale is saved in a Zend_Registry entry with key 'Zend_Locale'.

There are basically three usecases for the Locale Resource Plugin. Each of them should be used depending on the applications need.

Autodetect the locale to use

Without specifying any options for Zend_Application_Resource_Locale, Zend_Locale will detect the locale, which your application will use, automatically.

This detection works because your client sends the wished language within his HTTP request. Normally the clients browser sends the languages he wants to see, and Zend_Locale uses this information for detection.

But there are 2 problems with this approach:

  • The browser could be setup to send no language

  • The user could have manually set a locale which does not exist

In both cases Zend_Locale will fallback to other mechanism to detect the locale:

  • When a locale has been set which does not exist, Zend_Locale tries to downgrade this string.

    When, for example, en_ZZ is set it will automatically be degraded to en. In this case en will be used as locale for your application.

  • When the locale could also not be detected by downgrading, the locale of your environment (web server) will be used. Most available environments from Web Hosters use en as locale.

  • When the systems locale could not be detected Zend_Locale will use it's default locale, which is set to en per default.

For more informations about locale detection take a look into this chapter on Zend_Locale's automatic detection.

Autodetect the locale and adding a own fallback

The above autodetection could lead to problems when the locale could not be detected and you want to have another default locale than en. To prevent this, Zend_Application_Resource_Locale allows you to set a own locale which will be used in the case that the locale could not be detected.

例38 Autodetect locale and setting a fallback

The following snippet shows how to set a own default locale which will be used when the client does not send a locale himself.

; Try to determine automatically first,
; if unsuccessful, use nl_NL as fallback.
resources.locale.default = "nl_NL"

Forcing a specific locale to use

Sometimes it is useful to define a single locale which has to be used. This can be done by using the force option.

In this case this single locale will be used and the automatic detection is turned off.

例39 Defining a single locale to use

The following snippet shows how to set a single locale for your entire application.

; No matter what, the nl_NL locale will be used.
resources.locale.default = "nl_NL"
resources.locale.force = true

Configure cache template

When you have set no cache, Zend_Locale will set itself a cache with the file backend by default. But if you want to choose the backend or others options, you can use the name of a cache template or an instance of Zend_Cache_Core. For more informations look into 「Zend_Locale とそのサブクラスの高速化」.

例40 Defining a cache template to use

; Optionally you can also the cache template to use for caching:
resources.locale.cache = "locale"

Zend_Application_Resource_Log(日本語)

任意の数のログ・ライタとともに Zend_Logインスタンスを 生成するものが Zend_Application_Resource_Log です。 構成は Zend_Log::factory() メソッドに渡され、 ログ・ライタとフィルタの組合せを指定できます。 それから、ログ・インスタンスはイベントを記録するために、 後でブートストラップから取得されることがあります。

例41 ログ・リソース構成サンプル

下記は、ログ・リソースを設定する方法を示す、 INIスニペット・サンプルです。

resources.log.stream.writerName = "Stream"
resources.log.stream.writerParams.stream = APPLICATION_PATH "/../data/logs/application.log"
resources.log.stream.writerParams.mode = "a"
resources.log.stream.filterName = "Priority"
resources.log.stream.filterParams.priority = 4

利用可能なオプションについての詳細は、Zend_Log::factory() ドキュメント をチェックしてください。


Zend_Application_Resource_Mail(日本語)

Zend_Application_Resource_Mail は、 Zend_Mail 用のトランスポートをインスタンス化したり、 既定の名前やアドレス、さらに replyto の名前やアドレスを設定するために使われます。

トランスポートがインスタンス化されると、自動的に Zend_Mail に登録されます。ただし、 transport.register ディレクティブを FALSE に設定すると、この動作は行なわれなくなります。

例42 メール・リソース構成サンプル

下記は、メール・リソースプラグインを設定する方法を示す、 INIスニペット・サンプルです。

resources.mail.transport.type = smtp
resources.mail.transport.host = "smtp.example.com"
resources.mail.transport.auth = login
resources.mail.transport.username = myUsername
resources.mail.transport.password = myPassword
resources.mail.transport.register = true ; True by default

resources.mail.defaultFrom.email = john@example.com
resources.mail.defaultFrom.name = "John Doe"
resources.mail.defaultReplyTo.email = Jane@example.com
resources.mail.defaultReplyTo.name = "Jane Doe"

Zend_Application_Resource_Modules(日本語)

Zend_Application_Resource_Modulesは、 アプリケーションモジュールを初期化するために使われます。 モジュールのルートにBootstrap.phpファイルがあるなら、 Module_Bootstrapという名前のクラスを含みます、 ( "Module" のところがモジュール名です) そして、モジュールをブートするためにそのクラスを使用します。

Zend_Application_Module_Autoloaderのインスタンスは、 それを初期化するためにモジュール名とディレクトリを使用して、 モジュールのためにデフォルトで作成されます。

Modules リソースはデフォルトでは何も引数を受け取らないので、 設定で有効にするには空の配列として作成しなければなりません。 INI 形式で設定する場合は次のようになります。

resources.modules[] =

XML 形式で設定する場合は次のようになります。

<resources>
    <modules>
        <!-- Placeholder to ensure an array is created -->
        <placeholder />
    </modules>
</resources>

標準の PHP 配列を使用する場合は、単純に空の配列を作成します。

$options = array(
    'resources' => array(
        'modules' => array(),
    ),
);

フロントコントローラ・リソース依存

モジュール・リソースは、フロントコントローラ・リソース に依存します。 もちろん、あつらえのフロントコントローラ・リソースクラスまたはクラス・イニシャライザ・メソッドによって そのリソース自身の代用を提供できます。 "Frontcontroller" で終るリソース・プラグイン・クラスや "_initFrontController" という名前のイニシャライザ・メソッドである限りは。 (大文字と小文字の区別をしません)

例43 モジュールの設定

構成ファイルのプレフィックスまたはサブセクションとして モジュール名を使用しているモジュール固有の構成を指定できます。

たとえば、アプリケーションに "news" モジュールがあると仮定します。 下記は、そのモジュールでリソースの構成を示すINIXMLの例です。

[production]
news.resources.db.adapter = "pdo_mysql"
news.resources.db.params.host = "localhost"
news.resources.db.params.username = "webuser"
news.resources.db.params.password = "XXXXXXX"
news.resources.db.params.dbname = "news"
<?xml version="1.0"?>
<config>
    <production>
        <news>
            <resources>
                <db>
                    <adapter>pdo_mysql</adapter>
                    <params>
                        <host>localhost</host>
                        <username>webuser</username>
                        <password>XXXXXXX</password>
                        <dbname>news</dbname>
                    </params>
                    <isDefaultAdapter>true</isDefaultAdapter>
                </db>
            </resources>
        </news>
    </production>
</config>

例44 特定のモジュール・ブートストラップを取得する

時には、特定のモジュールのためにブートストラップ・オブジェクトを取得する必要があるかもしれません おそらくは別々のブートストラップ・メソッドを実行するためや、 それを構成するためのオートローダを引き出すために。 これは、モジュール・リソースのgetExecutedBootstraps()メソッドを使用して行なえます。

$resource = $bootstrap->getPluginResource('modules');
$moduleBootstraps = $resource->getExecutedBootstraps();
$newsBootstrap = $moduleBootstraps['news'];

Zend_Application_Resource_Multidb

Zend_Application_Resource_Multidb is used to initialize multiple Database connections. You can use the same options as you can with the Db Resource Plugin. However, for specifying a default connection, you can also use the 'default' directive.

例45 Setting up multiple Db Connections

Below is an example INI configuration that can be used to initialize two Db Connections.

[production]
resources.multidb.db1.adapter = "pdo_mysql"
resources.multidb.db1.host = "localhost"
resources.multidb.db1.username = "webuser"
resources.multidb.db1.password = "XXXX"
resources.multidb.db1.dbname = "db1"

resources.multidb.db2.adapter = "pdo_pgsql"
resources.multidb.db2.host = "example.com"
resources.multidb.db2.username = "dba"
resources.multidb.db2.password = "notthatpublic"
resources.multidb.db2.dbname = "db2"
resources.multidb.db2.default = true

例46 Retrieving a specific database adapter

When using this resource plugin you usually will want to retrieve a specific database. This can be done by using the resource's getDb(). The method getDb() returns an instance of a class that extends Zend_Db_Adapter_Abstract. If you have not set a default database, an exception will be thrown when this method is called without specifying a parameter.

$resource = $bootstrap->getPluginResource('multidb');
$db1 = $resource->getDb('db1');
$db2 = $resource->getDb('db2');
$defaultDb = $resource->getDb();

例47 Retrieving the default database adapter

Additionally, you can retrieve the default database adapter by using the method getDefaultDb(). If you have not set a default adapter, the first configured db adapter will be returned. Unless you specify FALSE as first parameter, then NULL will be returned when no default database adapter was set.

Below is an example that assumes the Multidb resource plugin has been configured with the INI sample above:

$resource = $bootstrap->getPluginResource('multidb');
$db2 = $resource->getDefaultDb();

// Same config, but now without a default db:
$db1 = $resource->getDefaultDb();
$null = $resource->getDefaultDb(false); // null

Zend_Application_Resource_Navigation(日本語)

Zend_Application_Resource_Navigationは、 Zend_Navigationインスタンスを構成するために使用できます。 構成オプションは、Zend_Navigation オプション毎にあります。

一旦ナビゲーション・インスタンスを構成すると、 それはデフォルトでインスタンスを Zend_View_Helper_Navigationに割り当てます、 そこから、後でそれを取得するかもしれません。

例48 ナビゲーション・リソース構成の例

下記は、ナビゲーション・リソースを設定する方法を示す、 INIスニペットの例です。

resources.navigation.pages.page1.label = "Label of the first page"
resources.navigation.pages.page1.route = "Route that belongs to the first page"

; Page 2 is a subpage of page 1
resources.navigation.pages.page1.pages.page2.type = "Zend_Navigation_Page_Uri"
resources.navigation.pages.page1.pages.page2.label = "Label of the second page"
resources.navigation.pages.page1.pages.page2.uri = "/url/to/page/2"

Zend_Application_Resource_Router(日本語)

Zend_Application_Resource_Routerは、 フロント・コントローラで登録されるようにルータを構成するために利用できます。 構成オプションは、 Zend_Controller_Router_Route オプション毎にあります。

例49 ルータ・リソース構成の例

下記は、ルータ・リソースを設定する方法を示す、 INIスニペットの例です。

resources.router.routes.route_id.route = "/login"
resources.router.routes.route_id.defaults.module = "user"
resources.router.routes.route_id.defaults.controller = "login"
resources.router.routes.route_id.defaults.action = "index"

; 任意でチェイン・ネーム・セパレータも設定できます。
resources.router.chainNameSeparator = "_"

チェイン・ネーム・セパレータについての詳細は、 この節 をご覧ください。


Zend_Application_Resource_Session(日本語)

Zend_Application_Resource_Session によって、任意にセッションSaveHandlerを初期化するだけでなく、 Zend_Sessionを構成できます。

セッション保存ハンドラを配置するためには、 単にリソースのsaveHandlerオプション・キーを渡してください。 (大文字と小文字の区別をしません) このオプションの値は、以下のうちの1つでしょう:

  • String: インスタンス化されるべきZend_Session_SaveHandler_Interfaceを 実装するクラスを示す文字列

  • Array: インスタンス化されるべきZend_Session_SaveHandler_Interfaceを実装しているクラスと そのコンストラクタに与えるオプションの配列を示す、 "class" 及び、任意で "options"キーを持つ配列

  • Zend_Session_SaveHandler_Interface: このインターフェースを実装するオブジェクト

渡されたオプション・キーはいずれも、 Zend_Sessionを構成するために、Zend_Session::setOptions()に渡されます。

例50 セッション・リソース構成サンプル

下記は、セッション・リソースを設定する方法を示すINIスニペット・サンプルです。 Zend_Session_SaveHandler_DbTableインスタンスを構成するだけではなく、 Zend_Sessionオプションをいくつか設定します。

resources.session.save_path = APPLICATION_PATH "/../data/session"
resources.session.use_only_cookies = true
resources.session.remember_me_seconds = 864000
resources.session.saveHandler.class = "Zend_Session_SaveHandler_DbTable"
resources.session.saveHandler.options.name = "session"
resources.session.saveHandler.options.primary[] = "session_id"
resources.session.saveHandler.options.primary[] = "save_path"
resources.session.saveHandler.options.primary[] = "name"
resources.session.saveHandler.options.primaryAssignment[] = "sessionId"
resources.session.saveHandler.options.primaryAssignment[] = "sessionSavePath"
resources.session.saveHandler.options.primaryAssignment[] = "sessionName"
resources.session.saveHandler.options.modifiedColumn = "modified"
resources.session.saveHandler.options.dataColumn = "session_data"
resources.session.saveHandler.options.lifetimeColumn = "lifetime"

最初にデータベースを起動してください!

もしZend_Session_SaveHandler_DbTableセッション保存ハンドラを構成しているなら、 それが機能するためのデータベース接続を最初に構成しなければなりません。 いずれでも、Dbリソースを用いてこれを実行してください。 "resources.db" キーが "resources.session" キーよりも優先されることを確認してください。 あるいは、データベースを初期化するあなた自身のリソースを書くことによって。 そして、特にデフォルトZend_Db_Tableアダプタを設定します。

Zend_Application_Resource_Translate

Zend_Application_Resource_Translate will initialize a Zend_Translate adapter based on the options passed to it.

The following configuration keys are recognized:

  • adapter : Zend_Translate adapter type. The default adapter is array if not specified.

  • data : path to translation.

  • locale : defining the locale to be used in translation. By default, the locale can be detected automatically or forcing with a Zend_Locale instance store in Zend_Registry with a single locale.

  • options : the options are different for each adapter. See the section 「アダプタのオプション」 for more details.

  • registry : the custom key to store the Zend_Translate instance in the registry. By default, the key is Zend_Translate.

  • cache : the name of the cache template or an instance of Zend_Cache_Core to use as cache for Zend_Translate_Adapter. The goal is to accelerate the loading specialy for the XML based files.

例51 Sample translate adapter resource configuration

Below is an example INI configuration that can be used to initialize the translate resource.

resources.translate.adapter = tmx
resources.translate.content = APPLICATION_PATH "/../data/locales"
resources.translate.scan = Zend_Translate::LOCALE_DIRECTORY

; Optionally you can also the cache template to use for caching:
resources.translate.cache = "languages"

Zend_Application_Resource_Useragent

Overview

This resource provides the ability to configure and instantiate Zend_Http_UserAgent for use within your application.

Quick Start

Using Zend_Http_UserAgent, including usage of the application resource, is covered in the UserAgent quick start. Below is a quick summary of typical options you might provide.

resources.useragent.wurflapi.wurfl_api_version = "1.1"
resources.useragent.wurflapi.wurfl_lib_dir = APPLICATION_PATH "/../library/Wurfl/1.1"
resources.useragent.wurflapi.wurfl_config_file = APPLICATION_PATH "/../library/Wurfl/1.1/resources/wurfl-config.php"

Configuration Options

Please see the UserAgent options section for details on available options.

Available Methods

init();

Called by the bootstrap object to initialize the resource. Calls the getUserAgent() method first (and returns the instance returned by that method); then, if the "view" resource is available, retrieves it and injects the UserAgent instance into the UserAgent view helper.

getUserAgent();

Instantiates a Zend_Http_UserAgent instance, using the configuration options provided in the application configuration.

Zend_Application_Resource_View(日本語)

Zend_Application_Resource_ViewZend_Viewの インスタンスを設定するために使用できます。設定オプションは Zend_Viewオプションに 従います。

一旦ビューのインスタンスを設定したら、 Zend_Controller_Action_Helper_ViewRendererのインスタンスを 作成して、Zend_Controller_Action_HelperBroker (後ほどそこから取得できるでしょう)でViewRendererを登録します。

例52 ビューリソースの設定例

下記はビューリソースを設定する方法を示す INI スニペット例です。

resources.view.encoding = "UTF-8"
resources.view.basePath = APPLICATION_PATH "/views/"

使用する doctype を定義

値について詳しくは、Doctype Helper をご覧ください。

例53 doctype 設定例

下記のスニペットは、doctype を設定する方法を示します。

resources.view.doctype = "HTML5"

使用するコンテンツタイプとエンコーディングを定義

値について詳しくは、HeadMeta Helper をご覧ください。

例54 コンテンツタイプとエンコーディングの設定例

下記のスニペットは、メタ Content-Type を設定する方法を示します。

resources.view.contentType = "text/html; charset=UTF-8"

例55 HTML5 ドキュメント用のエンコーディング設定例

下記のスニペットは、メタ charset を HTML5 スタイルで設定する方法を示します。

resources.view.doctype = "HTML5"
resources.view.charset = "UTF-8"