velocity-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nbu...@apache.org
Subject svn commit: r544637 - in /velocity/tools/branches/2.x/examples/showcase: WEB-INF/toolbox.xml display.vm toolmenu.vm
Date Tue, 05 Jun 2007 21:21:06 GMT
Author: nbubna
Date: Tue Jun  5 14:21:06 2007
New Revision: 544637

URL: http://svn.apache.org/viewvc?view=rev&rev=544637
Log:
add DisplayTool to showcase

Added:
    velocity/tools/branches/2.x/examples/showcase/display.vm   (with props)
Modified:
    velocity/tools/branches/2.x/examples/showcase/WEB-INF/toolbox.xml
    velocity/tools/branches/2.x/examples/showcase/toolmenu.vm

Modified: velocity/tools/branches/2.x/examples/showcase/WEB-INF/toolbox.xml
URL: http://svn.apache.org/viewvc/velocity/tools/branches/2.x/examples/showcase/WEB-INF/toolbox.xml?view=diff&rev=544637&r1=544636&r2=544637
==============================================================================
--- velocity/tools/branches/2.x/examples/showcase/WEB-INF/toolbox.xml (original)
+++ velocity/tools/branches/2.x/examples/showcase/WEB-INF/toolbox.xml Tue Jun  5 14:21:06
2007
@@ -94,6 +94,16 @@
     <parameter name="skip" value="month"/>
   </tool>
   <tool>
+    <key>display</key>
+    <scope>application</scope>
+    <class>org.apache.velocity.tools.generic.DisplayTool</class>
+    <parameter name="listDelim" value=", "/>
+    <parameter name="listFinalDelim" value=" and "/>
+    <parameter name="truncateMaxLength" value="30"/>
+    <parameter name="truncateSuffix" value="..."/>
+    <parameter name="defaultAlternate" value="null"/>
+  </tool>
+  <tool>
     <key>esc</key>
     <scope>application</scope>
     <class>org.apache.velocity.tools.generic.EscapeTool</class>

Added: velocity/tools/branches/2.x/examples/showcase/display.vm
URL: http://svn.apache.org/viewvc/velocity/tools/branches/2.x/examples/showcase/display.vm?view=auto&rev=544637
==============================================================================
--- velocity/tools/branches/2.x/examples/showcase/display.vm (added)
+++ velocity/tools/branches/2.x/examples/showcase/display.vm Tue Jun  5 14:21:06 2007
@@ -0,0 +1,87 @@
+## 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( 'DisplayTool' )
+<p>
+#set( $demo = $text.demo )
+$demo.thisPage.insert("#doclink( 'DisplayTool' true )").
+</p>
+
+#demoTableStart()
+
+## set quote character to empty string so values are not treated as strings
+#set( $quote = '' )
+
+#set( $desc = 'Formats a collection or array into the form "A, B and C".' )
+#demo1( 'display' 'list' 5 $desc )
+
+#set( $desc = 'Formats a collection or array into a string delimited by the second argument'
)
+#demo2( 'display' 'list' 5 $desc )
+
+#set( $desc = 'Formats a collection or array into a string delimited by the second argument,
except the last two arguments are delimited by the third argument' )
+#demo3( 'display' 'list' 5 $desc )
+
+#set( $desc = 'Limits the string output of the specified value to the configured max length
in characters (default is 30 characters). If the string gets curtailed, the configured suffix
(default is "...") is used as the ending of the truncated string.' )
+#demo1( 'display' 'truncate' 8 $desc )
+
+#set( $desc = 'Limits the string output of the second argument to the specified number of
characters.  If the string gets curtailed, the configured suffix (default is "...") is used
as the ending of the truncated string.' )
+#demo2( 'display' 'truncate' 5 $desc )
+
+#set( $desc = 'Limits the string output of the first argument to the configured max length
in characters (default is 30 characters). If the string gets curtailed, the specified suffix
is used as the ending of the truncated string.' )
+#demo2( 'display' 'truncate' 5 $desc )
+
+#set( $desc = 'Limits the string output of the second argument to the specified number of
characters. If the string gets curtailed, the specified suffix is used as the ending of the
truncated string.' )
+#demo3( 'display' 'truncate' 4 $desc )
+
+#set( $desc = 'Returns the configured default value ("null" by default) if the specified
value is null.' )
+#demo1( 'display' 'alt' 8 $desc )
+
+#set( $desc = 'Returns the second argument if first argument specified is null.' )
+#demo2( 'display' 'alt' 5 $desc )
+
+#demoCustom( 'display' )
+</table>
+
+#set( $primes = [1, 2, 3, 5, 7, 11] )
+<div align="center">
+  <a name="fullDemo"><h3>$demo.mainExampleHeader</h3></a>
+<form method="post" action="$link.self.anchor('fullDemo')">
+<textarea name="demo" rows="7" cols="65">##
+#if( $params.demo )##
+$params.demo##
+#else##
+${esc.d}primes
+${esc.d}display.list(${esc.d}primes)
+${esc.d}display.truncate("This sentence should be truncated at 30 characters.")
+${esc.d}display.truncate("This will be cut at 15.", 15)
+${esc.d}display.alt(${esc.d}primes)
+${esc.d}display.alt(${esc.d}null, "--")##
+#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>

Propchange: velocity/tools/branches/2.x/examples/showcase/display.vm
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: velocity/tools/branches/2.x/examples/showcase/toolmenu.vm
URL: http://svn.apache.org/viewvc/velocity/tools/branches/2.x/examples/showcase/toolmenu.vm?view=diff&rev=544637&r1=544636&r2=544637
==============================================================================
--- velocity/tools/branches/2.x/examples/showcase/toolmenu.vm (original)
+++ velocity/tools/branches/2.x/examples/showcase/toolmenu.vm Tue Jun  5 14:21:06 2007
@@ -27,6 +27,7 @@
 #toolMenuItem( $llink 'context' )
 #toolMenuItem( $llink 'cookies' )
 #toolMenuItem( $llink 'date' )
+#toolMenuItem( $llink 'display' )
 #toolMenuItem( $llink 'esc' )
 #toolMenuItem( $llink 'import' )
 #toolMenuItem( $llink 'link' )



Mime
View raw message