<?xml version="1.0" encoding="Shift_JIS"?>

<document>

    <properties>
        <title>ViewRenderTool</title>
        <author email="sidler@apache.org">Gabriel Sidler</author>
        <projectfile>xdocs-ja/view/menu.xml</projectfile>
        <translator email="shinobu@ieee.org">Shinobu Kawai</translator>
        <translator email="nekop@programmers.jp">木村 貴由</translator>
        <original>ViewRenderTool</original>
     </properties>

    <body>

    <section name="ViewRenderTool Reference Documentation" alias="ViewRenderTool リファレンスドキュメント">

        <primary>
        <p>This tool exposes methods to evaluate the given strings as VTL
        (Velocity Template Language) and automatically using the current context.</p>
        </primary>
        <p>与えられた文字列をVTL(Velocity テンプレート言語)として評価するメソッドを提供するツールです。
        その際、自動的にカレントコンテキストを使用します。</p>

        <toolinfo>
            <version>@@@version@@@, @@@date@@@</version>
            <clazz>org.apache.velocity.tools.view.tools.ViewRenderTool</clazz>
            <name>$render</name>
            <author email="nathan@esha.com">Nathan Bubna</author>
            <config-example>&lt;tool&gt;
  &lt;key&gt;render&lt;/key&gt;
  &lt;scope&gt;request&lt;/scope&gt;
  &lt;class&gt;org.apache.velocity.tools.view.tools.ViewRenderTool&lt;/class&gt;
&lt;/tool&gt;</config-example>
        </toolinfo>

        <methods/>

    </section>


    <section name="eval()">
        <primary>
        <method name="eval()">

            <abstract>
                Evaluates a String containing VTL using the current context, and
                returns the result as a String.
            </abstract>

            <signature>
                String eval(String vtl)
            </signature>

            <parameters>
                <parameter name="vtl">
                    The code to be evaluated.
                </parameter>
            </parameters>

            <returns>
                The evaluated code as a String.
            </returns>

            <description>
                <p>Evaluates a String containing VTL using the current context, and
                returns the result as a String.  If this fails, then <code>null</code>
                will be returned.  This evaluation is not recursive.</p>

<sourcecode>#set( $list = [1,2,3] )
#set( $object = '$list' )
#set( $method = 'size()' )
$render.eval("${object}.$method")</sourcecode>

<p>This will produce the following output:</p>

<sourcecode>3</sourcecode>

		</description>
            </method>
        </primary>

        <method name="eval()">

            <abstract>
                カレントコンテキストを使用してVTLを含めた文字列を評価し、
                結果を文字列として返却します。
            </abstract>

            <signature>
                String eval(String vtl)
            </signature>

            <parameters>
                <parameter name="vtl">
                    評価対象のコード。
                </parameter>
            </parameters>

            <returns>
                コードを評価した結果の文字列。
            </returns>

            <description>
                <p>カレントコンテキストを使用してVTLを含めた文字列を評価し、
                結果を文字列として返却します。失敗した場合、<code>null</code>
                が返却されます。この評価は再起的ではありません。</p>

<sourcecode>#set( $list = [1,2,3] )
#set( $object = '$list' )
#set( $method = 'size()' )
$render.eval("${object}.$method")</sourcecode>

<p>これは以下の出力を生成します:</p>

<sourcecode>3</sourcecode>

		</description>
            </method>

    </section>

    <section name="recurse()">
        <primary>
        <method name="recurse()">

            <abstract>
                Recursively evaluates a String containing VTL using the
                current context, and returns the result as a String.
            </abstract>

            <signature>
                String recurse(String vtl)
            </signature>

            <parameters>
                <parameter name="vtl">
                    The code to be evaluated.
                </parameter>
            </parameters>

            <returns>
                The evaluated code as a String
            </returns>

            <description>
                <p>Recursively evaluates a String containing VTL using the
                current context, and returns the result as a String. It
                will continue to re-evaluate the output of the last
                evaluation until an evaluation returns the same code
                that was fed into it.</p>

<sourcecode>#macro( say_hi )hello world!#end
#set( $foo = '#say_hi()' )
#set( $bar = '$foo' )
$render.recurse('$bar')</sourcecode>

<p>This will produce the following output:</p>

<sourcecode>hello world!</sourcecode>

		</description>
            </method>
        </primary>

        <method name="recurse()">

            <abstract>
                カレントコンテキストを使用してVTLを含めた文字列を再起的に評価し、
                結果を文字列として返却します。
            </abstract>

            <signature>
                String recurse(String vtl)
            </signature>

            <parameters>
                <parameter name="vtl">
                    評価対象のコード。
                </parameter>
            </parameters>

            <returns>
                コードを評価した結果の文字列。
            </returns>

            <description>
                <p>カレントコンテキストを使用してVTLを含めた文字列を再起的に評価し、
                結果を文字列として返却します。
                評価の結果が評価前のコードと同じになるまで直前の結果を繰り返し評価します。
                </p>

<sourcecode>#macro( say_hi )hello world!#end
#set( $foo = '#say_hi()' )
#set( $bar = '$foo' )
$render.recurse('$bar')</sourcecode>

<p>これは以下の出力を生成します:</p>

<sourcecode>hello world!</sourcecode>

		</description>
            </method>

    </section>
 </body>
</document>


