## 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. #* * This template exists to automatically generate demos for a tool. * It expects the following values to be set before it is parsed: * $toolname -> should be the context key of the tool * $toolclass -> should be the actual Class of the tool * $toollink -> a URL for the javadoc of the tool Class on velocity.apache.org * This is usually set copying the $doclink reference that is set * whenever the #doclink() macro is used. * Optionally, you can also set: * $toolDemo -> to specify the default text for the full demo at the bottom * * If you're wondering why this is a template, instead of a macro; * it is because it takes less memory in the cache this way. *# #set( $demo = $text.demo ) #set( $tool = $class.inspect($toolclass) )
$demo.function | $demo.description | |
---|---|---|
$call | #if( !$method.takesParameters() ) ## simply call the method #set( $result = $call ) #set( $result = $render.eval($call) )#if( $result == $call )$text.demo.nullResult#else$result#end | #else ## create a form to allow the user to input values and call the method #end ## look for a description of the specific method #set( $desc = $text.get("${toolname}.${method.uniqueName}") ) #if( !$desc.exists ) ## look for a description of all methods with that name #set( $desc = $text.get("${toolname}.${method.name}") ) #if( !$desc.exists ) #if( $method.propertyName ) ## look for a tool-specific generic property description #set( $desc = $text.get("${toolname}.propertyDescription").insert($method.propertyName) ) #else ## look for a generic method descirption for the tool #set( $desc = $text.get("${toolname}.methodDescription") ) #end #if( !$desc.exists ) #if( $method.uniqueName eq 'toString' ) ## use the generic toString description #set( $desc = $demo.toString ) #else ## use the generic description missing message #set( $desc = $demo.descriptionMissing ) #end #end #end #end$desc |
$text.demo.tryAnything |
$render.eval($params.fullDemo)#end