.. http://www.lassosoft.com/Language-Guide-Calling-Lasso .. _calling-lasso: ************* Calling Lasso ************* This chapter describes two different methods of calling Lasso: either using Lasso as a script processor on the command line or using Lasso as a web application server through the web browser. This information is presented at the start of this part as it is vital to understanding the rest of the topics and examples given in this guide. Calling Lasso Web Pages ======================= .. index:: delimiters, no_square_brackets Lasso is most often used to serve web applications. Lasso code can be embedded in HTML pages and executed before they are served to web visitors. A page that includes Lasso code within it is referred to as a :dfn:`Lasso page`. Lasso code is embedded within a regular HTML file by inserting the code between a certain set of delimiters. These delimiters consist of an opening and a closing element. Outside of these delimiting elements, all text is treated as if it were plain text string literals. Such text is not interpreted by Lasso. Between the delimiters, all text is parsed and executed as Lasso code. In this manner, an HTML file becomes a template, with the final resulting data being the combination of whatever plain text the file contained, plus whatever text was generated via any contained Lasso code. The available delimiting elements are described below. The "|dot| .." shown between the delimiters illustrates where Lasso code would be inserted by the developer. :: :: = ... ?> :: [ ... ] All three delimiters will produce identical results. Multiple expressions can be contained between these delimiters. The result from each contained expression is converted to a string and then concatenated together along with any plain text existing outside of the delimiters. Although square brackets (``[ ... ]``) are enabled by default, they can be disabled by placing ``[no_square_brackets]``, usually at the top of the page, outside the delimiters. Once the Lasso parser encounters ``[no_square_brackets]``, square brackets are be turned "off" and any subsequently encountered square brackets will be treated as plain text. Turning square brackets off works on a per-file basis, and cannot be turned back on once they are off. .. _calling-lasso-web-ex: To illustrate how Lasso code is embedded within a Lasso page, the following code may be stored in a file named "test.lasso" contained within the web server root. ::
= 'The current date is ' + date ?>.
The above begins with plain HTML markup, then adds two Lasso code expressions into the document using a delimiter pair. When this file is loaded through a browser, the code shown above is executed and the result is returned to the web browser. If the embedded message is not visible in the web browser or an error occurs, then you should make sure that Lasso Server has been properly installed on your machine. See the appropriate installation instructions for your operating system elsewhere in this guide. .. _calling-lasso-cli: Calling Lasso from the CLI ========================== Lasso code can be saved in a file and then executed on the command line. This style of execution happens directly and does not require a web server or web browser. Additionally, since a web server or web request is not in effect during such execution, none of the web serving--specific functionality is available in this context. (For more information on the command-line tools that come as part of the Lasso platform, see the :ref:`command-line-tools` chapter.) Using the lasso9 Tool --------------------- .. index:: lasso9 The :program:`lasso9` executable is a tool included with Lasso that handles the parsing and execution of Lasso code from the command line. For example, the following text could be placed into a file "test.lasso":: 'The current date is ' + date The file can be executed from the terminal using lasso9. If the reader has created such a test file and has done a :command:`cd` to the location of the file, then the file can be executed like so: .. code-block:: none $> lasso9 ./test.lasso The current date is 2012-08-08 15:07:25 If the terminal reports the command was not found, or you receive some other error, then you should make sure that Lasso has been installed properly on your machine. See the appropriate server installation guide section for your operating system for complete instructions. When running Lasso code on the command line, delimiters are not required, though they can be used. By default, text is assumed to consist of Lasso code only, unless the file's text begins with an open angle bracket (``<``), in which case it is assumed to start out as plain text. For example, the :ref:`test file shown in "Calling Lasso Web Pages"