| ## Licensed to the Apache Software Foundation (ASF) under one |
| ## or more contributor license agreements. See the NOTICE file |
| ## distributed with this work for additional information |
| ## regarding copyright ownership. The ASF licenses this file |
| ## to you under the Apache License, Version 2.0 (the |
| ## "License"); you may not use this file except in compliance |
| ## with the License. You may obtain a copy of the License at |
| ## |
| ## http://www.apache.org/licenses/LICENSE-2.0 |
| ## |
| ## Unless required by applicable law or agreed to in writing, |
| ## software distributed under the License is distributed on an |
| ## "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| ## KIND, either express or implied. See the License for the |
| ## specific language governing permissions and limitations |
| ## under the License. |
| #title( 'ResourceTool' ) |
| <p> |
| #set( $demo = $text.demo ) |
| $demo.thisPage.insert("#doclink( 'ResourceTool' true )"). This tool |
| is similar to the <a href="$link.relative('link.vm')">LinkTool</a> in that most methods |
| return a new object that has mostly the same methods as the original, allowing you |
| to build up parameters elegantly and simply, rather than try to remember how to use |
| methods with many parameters that must be in a specific order. So, you can access a |
| resource with the key 'hello.whoever' in the 'otherStuff' bundle with one message |
| argument like this: |
| <pre> |
| ${esc.d}text.hello.whoever.bundle('otherStuff').insert('World') |
| </pre> |
| instead of like this: |
| <pre> |
| ${esc.d}text.get('hello.whoever','otherStuff', $null, 'World') |
| </pre> |
| While the former is somewhat longer, it is much more understandable and flexible. |
| </p> |
| |
| #demoTableStart() |
| |
| #set( $desc = 'Returns the resource with the specified name, if it exists.' ) |
| #demo1( 'text' 'get' 9 $desc ) |
| |
| #set( $desc = 'Returns a new $text that will search only the specified bundle (if it exists) for the resource "foo".' ) |
| #demo1( 'text.foo' 'bundle' 9 $desc ) |
| |
| #set( $quote = '' ) |
| #set( $desc = 'Returns a new $text that will try to find the resource "foo" for the specified Locale.' ) |
| #demo1( 'text.foo' 'locale' 9 $desc ) |
| |
| #set( $quote = '"' ) |
| #set( $desc = 'Returns the resource "hello.whoever" with the specified value inserted.' ) |
| #demo1( 'text.hello.whoever' 'insert' 9 $desc ) |
| |
| #set( $desc = 'Returns the resource "baz" with the specified values inserted.' ) |
| #demo2( 'text.baz' 'insert' 9 $desc ) |
| |
| #demoCustom( 'text' ) |
| </table> |
| |
| <div align="center"> |
| <a name="fullDemo"><h3>$demo.mainExampleHeader</h3></a> |
| <form method="post" action="$link.self.anchor('fullDemo')"> |
| <textarea name="demo" rows="6" cols="65">## |
| #if( $params.demo )## |
| $params.demo## |
| #else## |
| ${esc.d}text.foo |
| ${esc.d}text.hello.whoever |
| ${esc.d}text.hello.whoever.insert(${esc.d}text.world) |
| ${esc.d}text.bundle('otherStuff').foo## |
| #end## |
| </textarea> |
| <br> |
| <input type="submit" value="$demo.try"> |
| #if( $params.layout ) |
| <input type="hidden" name="layout" value="$params.layout"> |
| #end |
| </form> |
| |
| #if( $params.demo ) |
| $demo.mainResultsIntro: |
| <pre> |
| $render.eval($params.demo) |
| </pre> |
| #end |
| </div> |