calcn — evaluate the enclosed arithmetic expression or Perl block
Attribute | Pos. | Req. | Default | Description |
---|---|---|---|---|
interpolate | 0 | interpolate input? | ||
reparse | 1 | interpolate output? |
The tag evaluates the enclosed arithmetic expression or a Perl block. The last expression evaluated (return value) is returned back to the client page.
The tag is only a convenience and otherwise identical to [calc]
,
except that it does not interpolate tag body by default.
Example: Simple non-interpolating block
The example will, since [calcn]
is used, directly return the quoted
content unmodified, instead of evaluating to "TEST":
[cgi name=test set=TEST hide=1] [calcn reparse=0] "[cgi test]" [/calcn]
Interchange 5.9.0:
Source: code/SystemTag/calcn.coretag
Lines: 12
# Copyright 2002-2007 Interchange Development Group and others # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. See the LICENSE file for details. # # $Id: calcn.coretag,v 1.4 2007-03-30 23:40:49 pajamian Exp $ UserTag calcn hasEndTag UserTag calcn Version $Revision: 1.4 $ UserTag calcn MapRoutine Vend::Interpolate::tag_calc
Source: lib/Vend/Interpolate.pm
Lines: 2823
sub tag_calc { my($body) = @_; my $result; if($Vend::NoInterpolate) { logGlobal({ level => 'alert' }, "Attempt to interpolate perl/ITL from RPC, no permissions." ); } $Items = $Vend::Items; if($MVSAFE::Safe) { $result = eval($body); } else { init_calc() if ! $Vend::Calc_initialized; $result = $ready_safe->reval($body); } if ($@) { my $msg = $@; $Vend::Session->{try}{$Vend::Try} = $msg if $Vend::Try; logGlobal({ level => 'debug' }, "Safe: %s\n%s\n" , $msg, $body); logError("Safe: %s\n%s\n" , $msg, $body); return $MVSAFE::Safe ? '' : 0; } return $result; }