Sledge::Plugin::Prototype - HTML::Prototype wrapper
package Foo::Pages::Bar; use Sledge::Plugin::Prototype; # just use
# you can use parameter 'prototype' if template engine is tt [% prototype.define_javascript_functions %]
# or in your dispatcher
sub dispatch_prototype_js {
shift->show_prototype_js;
}
# use the helper methods
<div id="view"></div>
<textarea id="editor" cols="80" rows="24"></textarea>
[% prototype.observe_field( 'editor', 'http://foo.bar/baz', { 'update' => 'view' } ) %]
Sledge::Plugin::Prototype はHTML::Prototypeのwrapperです。
Sledge::Plugin::Prototype を useすることでPagesクラスにprototypeメソッドと、
show_prototype_jsメソッドを追加します。
テンプレートエンジンにSledge::Template::TTを利用している場合、
テンプレートのパラメータにprototypeをセットします。
dispatchでshow_prototype_jsを使用すると、HTML::Prototypeの使うprototype.jsのJavaScript
ソースをcontent-type:text/javascriptで出力します。
Yasuhiro Horiuchi <horiuchi@vcube.com>