There is only one type of intrinsic data structure in BEE: array of strings. Simple variables are in fact single element array. In that case, the element index to the array is omitted and assumed to be blank (""). We call this the default element.
var a = "x";
display "{a}<br>
"; // Output: x
display "{a|list}<br>
"; // Output: =>x
(The "|list" part specifies a Conversion that converts an array to a presentable string. Conversion is discussed in the next section.)
Now let's illustrate the idea by storing the string "Hello World" into a variable and having the script display the variable instead:
<script language="bee"> var hw = "Hello World";
display "<h1>{hw}
</h1>
";
</script>
The same can be done using BEE Tag, without the BEE section definition (<script ...> and </script>):
<bee var="hw" value="Hello World">
<bee value="<h1>{hw}
</h1>
">
Please note that each BEE tag (<bee ...>) is a BEE Section itself and is therefore replaced by its output before the web page is sent to the client browser. However, white spaces between BEE Tags are not part of the BEE Section and therefore are sent to the client browser untouched. The above example can be written as:
<bee var="hw" value="Hello World">
<h1><bee value="{hw}">
</h1>
BEE makes it easy to display variable, even "naked". Look at this:
<bee var="hw" value="Hello World">
<h1>${hw}
</h1>
Here ${hw} is translated to <bee value="{hw}">. BEE Values in the form of {var} is interpreted as such only within BEE Section. When it is not in a BEE Section (naked), a dollar sign must be put in front of a BEE Value to allow the parser to pick it up (i.e. dressing up the "naked" BEE Value.)
As a side-topic, you can count the number of elements in an array or the number of characters in an element string using the "sizeof" operator ({#...}). However, please be careful when using "sizeof". It counts the number of elements in an array unless the element is explicitly specified, even if it is the default element.
var arr = "(array)one,two,three,four";
// Number of elements in array arr
display "{#arr}
"; // Output: 4
// Number of characters in the second element of arr (first is 0)
display "{#arr:#1}
"; // Output: 3
var v = "hello";
// Number of elements in array v
display "{#v}
"; // Output: 1
// Number of characters in the default element of v
display "{#v:}
"; // Output: 5
|