====== AlTemplate テンプレート ====== ===== 概要 ===== * 文法にeRubyを採用したテンプレートシステムです。 * Ruby付属のERBクラスを使わず、独自実装しています。 * テンプレートコンパイル結果のキャッシュによる高速化が可能です。 ===== 簡単な使い方 ===== 1. テンプレートファイルを用意します。 <%= header_section %> Test <%= body_section %>

<%=h @my_message %>

<%= footer_section %>
2. main.rb中で、同ファイルを指定してレンダリングを指示します。 * インスタンス変数がテンプレート中で展開されます * AlTemplate.run()にテンプレートファイル名を指定します。 require 'al_template' class HelloController < AlController def action_index() @my_message = "Hello world." AlTemplate.run( 'index.rhtml' ) end end ==== テンプレートの読み込みパス仕様 ==== ^ 記述方法 ^ 説明 ^ | AlTemplate.run("template.rhtml") | al_config.rb内のAL_TEMPLATE_DIRで指定したディレクトリから読み込み | | AlTemplate.run("./template.rhtml") | コントローラと同じディレクトリから読み込み | | AlTemplate.run("/PATH/TO/template.rhtml") | 絶対パスで指定したディレクトリから読み込み | ===== 機能詳細 ===== * [[設定 al_config]] * [[テンプレートファイル]] * [[その他の使用方法]]