Location: PHPKode > projects > Open Power Template > docs/Opt/guide.data-formats.expressions.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
<html xmlns="http://www.w3.org/1999/xhtml" lang="pl">
	<meta http-equiv="content-type" content="text/html; charset=utf-8" />
	<meta name="robots" content="all" />

	<title>Formats and expressions - Open Power Template</title>
	<link rel="stylesheet" type="text/css" href="design/generic.css" media="all"  />
	<link rel="stylesheet" type="text/css" href="design/print.css" media="print" />
	<!--[if lte IE 6]><link rel="stylesheet" href="design/ie.css" type="text/css" /><![endif]-->	
	<!--[if IE 7]><link rel="stylesheet" href="design/ie7.css" type="text/css" /><![endif]-->

<div id="wrap">
	<div id="header">
		<h1>Open Power Template 2.0</h1>
		<h2>Formats and expressions</h2>
		<p class="generated">@ 02.09.2010</p>
		<p class="location"><a href="index.html"><strong>User manual</strong></a> &raquo; <a href="guide.html">Programmer's Guide</a> &raquo; <a href="guide.data-formats.html">Data formats</a> &raquo; <a href="guide.data-formats.expressions.html">Formats and expressions</a></p>
	<div id="content"><dl class="location"><dt><a href="guide.data-formats.html">4.6. Data formats</a><br/>4.6.2. Formats and expressions</dt><dd class="prev">4.6.1. Available data formats<br/><a href="guide.data-formats.available.html">&laquo; Previous</a></dd><dd class="next">4.7. Template inheritance<br/><a href="guide.inheritance.html">Next &raquo;</a></dd></dl>	<h1>4.6.2. Formats and expressions</h1><p>A lot of OPT functions can operate on whole containers, executing the base function on all of their elements. For example, we can capitalize a single string: <code>capitalize('string')</code> or a container of strings: <code>capitalize($containerOfStrings)</code>.</p>

<h2>Formats and functions</h2>

<p>In case of the following code:</p>

<pre><code>{@container = someFunction($otherContainer)}

<p>The result container should always be an array - the <code>$otherContainer</code> elements are repacked to the generic format, so that the compiler could generate a proper code for them.</p>

<h2>Formats and assignment operators</h2>

<p>In the following code:</p>

<pre><code>{@bar is $foo.bar}

<p>Nothing is repacked. The compiler detects that we want to take a sub-container into another variable and will automatically set the correct format for the new variable.</p>

<h2>Formats and other expressions</h2>

<p>In the complicated expressions, like <code>$foo.bar + $foo.joe</code> the variables behave according to their formats. However, some results may have no sense:</p>

<pre><code>{$joe is $foo~$bar}

<p>If <code>$foo</code> and <code>$bar</code> are containers, the final result may be strange or even produce PHP warnings or fatal errors. If you are worried about the template security, you should take a look at the configuration directives that allow to control the syntax features.</p>
<dl class="location location-bottom"><dt>4.6.2. Formats and expressions<br/><a href="guide.data-formats.html">4.6. Data formats</a></dt><dd class="prev"><a href="guide.data-formats.available.html">&laquo; Previous</a><br/>4.6.1. Available data formats</dd><dd class="next"><a href="guide.inheritance.html">Next &raquo;</a><br/>4.7. Template inheritance</dd></dl>		</div>
	<div id="footer">
		<p>Copyright &copy; <a href="http://www.invenzzia.org/">Invenzzia Group 2008-2009</a></p>
		<p>Available under the terms of license: <a href="http://www.gnu.org/licenses/fdl.html">GNU Free Documentation License 1.2</a></p>
		<p>Generated by <strong>TypeFriendly 0.1.4</strong> by <a href="http://www.invenzzia.org/">Invenzzia</a></p>

Return current item: Open Power Template