Skip to content

Commit

Permalink
[update] 'doc/users-guide.{txt,html}'
Browse files Browse the repository at this point in the history
  • Loading branch information
kwatch committed Mar 22, 2011
1 parent b45ab4a commit 2ed6eb1
Show file tree
Hide file tree
Showing 2 changed files with 150 additions and 0 deletions.
77 changes: 77 additions & 0 deletions doc/users-guide.html
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,8 @@ <h3 class="section2">Table of Contents</h3>
</li>
<li><a href="#lang-c">C</a>
</li>
<li><a href="#lang-cpp">C++</a>
</li>
<li><a href="#lang-java">Java</a>
</li>
<li><a href="#lang-scheme">Scheme</a>
Expand Down Expand Up @@ -2033,6 +2035,81 @@ <h3 class="section2">C</h3>
<br>


<a name="lang-cpp"></a>
<h3 class="section2">C++</h3>
<a name="example.ecpp"></a>
<div class="program_caption">
example.ecpp</div>
<pre class="program"><strong>&lt;%
#include &lt;string&gt;
#include &lt;iostream&gt;
#include &lt;sstream&gt;

int main(int argc, char *argv[])
{
std::stringstream _buf;
%&gt;</strong>
&lt;html&gt;
&lt;body&gt;
&lt;p&gt;Hello <strong>&lt;%= argv[0] %&gt;</strong>!&lt;/p&gt;
&lt;table&gt;
&lt;tbody&gt;
<strong>&lt;% for (int i = 1; i &lt; argc; i++) { %&gt;</strong>
&lt;tr bgcolor="<strong>&lt;%= i % 2 == 0 ? "#FFCCCC" : "#CCCCFF" %&gt;</strong>"&gt;
&lt;td&gt;<strong>&lt;%= i %&gt;</strong>&lt;/td&gt;
&lt;td&gt;<strong>&lt;%= argv[i] %&gt;</strong>&lt;/td&gt;
&lt;/tr&gt;
<strong>&lt;% } %&gt;</strong>
&lt;/tbody&gt;
&lt;/table&gt;
&lt;/body&gt;
&lt;/html&gt;
<strong>&lt;%
std::string output = _buf.str();
std::cout &lt;&lt; output;
return 0;
}
%&gt;</strong>
</pre>
<a name="example_c.result"></a>
<div class="terminal_caption">
compiled source code</div>
<pre class="terminal">$ erubis -l cpp example.ecpp
#line 1 "example.ecpp"

#include &lt;string&gt;
#include &lt;iostream&gt;
#include &lt;sstream&gt;

int main(int argc, char *argv[])
{
std::stringstream _buf;

_buf &lt;&lt; "&lt;html&gt;\n"
" &lt;body&gt;\n"
" &lt;p&gt;Hello "; _buf &lt;&lt; (argv[0]); _buf &lt;&lt; "!&lt;/p&gt;\n"
" &lt;table&gt;\n"
" &lt;tbody&gt;\n";
for (int i = 1; i &lt; argc; i++) {
_buf &lt;&lt; " &lt;tr bgcolor=\""; _buf &lt;&lt; (i % 2 == 0 ? "#FFCCCC" : "#CCCCFF"); _buf &lt;&lt; "\"&gt;\n"
" &lt;td&gt;"; _buf &lt;&lt; (i); _buf &lt;&lt; "&lt;/td&gt;\n"
" &lt;td&gt;"; _buf &lt;&lt; (argv[i]); _buf &lt;&lt; "&lt;/td&gt;\n"
" &lt;/tr&gt;\n";
}
_buf &lt;&lt; " &lt;/tbody&gt;\n"
" &lt;/table&gt;\n"
" &lt;/body&gt;\n"
"&lt;/html&gt;\n";

std::string output = _buf.str();
std::cout &lt;&lt; output;
return 0;
}

</pre>
<br>


<a name="lang-java"></a>
<h3 class="section2">Java</h3>
<a name="Example.ejava"></a>
Expand Down
73 changes: 73 additions & 0 deletions doc/users-guide.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2112,6 +2112,79 @@ fputs(" </tbody>\n"
.====================


.$$ C++ | lang-cpp

.? example.ecpp
.-------------------- example.ecpp
{{*<%
#include <string>
#include <iostream>
#include <sstream>

int main(int argc, char *argv[])
{
std::stringstream _buf;
%>*}}
<html>
<body>
<p>Hello {{*<%= argv[0] %>*}}!</p>
<table>
<tbody>
{{*<% for (int i = 1; i < argc; i++) { %>*}}
<tr bgcolor="{{*<%= i % 2 == 0 ? "#FFCCCC" : "#CCCCFF" %>*}}">
<td>{{*<%= i %>*}}</td>
<td>{{*<%= argv[i] %>*}}</td>
</tr>
{{*<% } %>*}}
</tbody>
</table>
</body>
</html>
{{*<%
std::string output = _buf.str();
std::cout << output;
return 0;
}
%>*}}
.--------------------

.? compiled source code
.==================== example_c.result
$ erubis -l cpp example.ecpp
.#.<<<:! (cd guide.d; erubis -l cpp example.ecpp)
#line 1 "example.ecpp"

#include <string>
#include <iostream>
#include <sstream>

int main(int argc, char *argv[])
{
std::stringstream _buf;

_buf << "<html>\n"
" <body>\n"
" <p>Hello "; _buf << (argv[0]); _buf << "!</p>\n"
" <table>\n"
" <tbody>\n";
for (int i = 1; i < argc; i++) {
_buf << " <tr bgcolor=\""; _buf << (i % 2 == 0 ? "#FFCCCC" : "#CCCCFF"); _buf << "\">\n"
" <td>"; _buf << (i); _buf << "</td>\n"
" <td>"; _buf << (argv[i]); _buf << "</td>\n"
" </tr>\n";
}
_buf << " </tbody>\n"
" </table>\n"
" </body>\n"
"</html>\n";

std::string output = _buf.str();
std::cout << output;
return 0;
}

.====================


.$$ Java | lang-java

Expand Down

0 comments on commit 2ed6eb1

Please sign in to comment.