summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormakoto kuwata <kwa@kuwata-lab.com>2011-03-22 16:26:45 +0900
committermakoto kuwata <kwa@kuwata-lab.com>2011-03-22 17:00:30 +0900
commit2ed6eb1739a87b80e53b74cf878dd6b6b815a008 (patch)
treeed22c63ba44d954eaecd6142ce87c7adc9cae73b
parentb45ab4a8266db2f3d4e5db24a090403758202165 (diff)
downloaderubis-2ed6eb1739a87b80e53b74cf878dd6b6b815a008.tar.gz
[update] 'doc/users-guide.{txt,html}'
-rw-r--r--doc/users-guide.html77
-rw-r--r--doc/users-guide.txt73
2 files changed, 150 insertions, 0 deletions
diff --git a/doc/users-guide.html b/doc/users-guide.html
index 9e9c501..53d4b62 100644
--- a/doc/users-guide.html
+++ b/doc/users-guide.html
@@ -128,6 +128,8 @@ Erubis now supports Ruby 1.9.
</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>
@@ -2033,6 +2035,81 @@ fputs(" &lt;/tbody&gt;\n"
<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>
diff --git a/doc/users-guide.txt b/doc/users-guide.txt
index 85431af..f1d61bb 100644
--- a/doc/users-guide.txt
+++ b/doc/users-guide.txt
@@ -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