Mercurial Hosting > luan
diff website/src/manual.html.luan @ 465:47c7de1f2322
documentation work
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Thu, 07 May 2015 22:10:45 -0600 |
parents | eddf7c73373b |
children | 9b51e2413cab |
line wrap: on
line diff
--- a/website/src/manual.html.luan Thu May 07 21:31:19 2015 -0600 +++ b/website/src/manual.html.luan Thu May 07 22:10:45 2015 -0600 @@ -60,6 +60,7 @@ <li><a href="#for">For Statement</a></li> <li><a href="#fn_stmt">Function Calls as Statements</a></li> <li><a href="#local_stmt">Local Declarations</a></li> + <li><a href="#template_stmt">Template Statements</a></li> </ul> </li> <li> @@ -75,6 +76,7 @@ <li><a href="#constructors">Table Constructors</a></li> <li><a href="#fn_calls">Function Calls</a></li> <li><a href="#fn_def">Function Definitions</a></li> + <li><a href="#template_expr">Template Expressions</a></li> </ul> </li> <li><a href="#visibility">Visibility Rules</a></li> @@ -1107,6 +1109,28 @@ The visibility rules for local variables are explained in <a href="#visibility">Visibility Rules</a>. +<h4 margin-top="1em"><a name="template_stmt">Template Statements</a></h4> + +<p>Template statements are based on <a href="#template_expr">template exressions</a> and provide the full equivalent of <a href="http://en.wikipedia.org/wiki/JavaServer_Pages">JSP</a> but in a general way. Template statements write the equivalent template exression to standard output. For example:</p> + +<p><tt><pre><%=Html.encode[[ + local name = "Bob" + %> + Hello <%=name%>! + Bye <%=name%>. + <% +]]%></pre></tt></p> + +<p>is equivalent to the code:</p> + +<p><tt><pre><%=Html.encode[[ + local name = "Bob" + require("luan:Io").stdout.write( %> + Hello <%=name%>! + Bye <%=name%>. + <% ) +]]%></pre></tt></p> + <h3 margin-top="1em"><a name="expressions">Expressions</a></h3> @@ -1223,13 +1247,11 @@ <h4 margin-top="1em"><a name="conversions">Coercions and Conversions</a></h4> <p> -Luan provides some automatic conversions between some -types and representations at run time. -String concatenation converts all of its arguments to strings. - -Luan also converts strings to numbers -whenever a number is expected. - +Luan generally avoids automatic conversions. +String concatenation automatically converts all of its arguments to strings. + +<p> +Luan provides library functions for explicit type conversions. @@ -1696,6 +1718,24 @@ then the function returns with no results. +<h4 margin-top="1em"><a name="template_expr">Template Expressions</a></h4> + +<p>Luan template expression are based on <a href="http://en.wikipedia.org/wiki/JavaServer_Pages">JSP</a>. Template expressions return multiple values. Here is an example:</p> + +<p><tt><pre><%=Html.encode[[ + local name = "Bob" + write( %>Hello <%=name%>!<% ) +]]%></pre></tt></p> + +<p>This is equivalent to the code:</p> + +<p><tt><pre> + local name = "Bob" + write( "Hello ", name, "!" ) +</pre></tt></p> + +<p>The strings in template expressions may be multiple lines.</p> + <h3 margin-top="1em"><a name="visibility">Visibility Rules</a></h3>