Skip to content

Commit

Permalink
[enhance] add examples for C++
Browse files Browse the repository at this point in the history
  • Loading branch information
kwatch committed Mar 22, 2011
1 parent 2ed6eb1 commit 73a613b
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 2 deletions.
9 changes: 7 additions & 2 deletions examples/basic/Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
all = example.rb example.php example.c example.java example.scm example.pl example.js
all = example.rb example.php example.c example.cpp example.java example.scm example.pl example.js

all: $(all)

Expand All @@ -12,6 +12,9 @@ example.php: example.ephp
example.c: example.ec
erubis -bl c example.ec > example.c

example.cpp: example.ecpp
erubis -bl cpp example.ecpp > example.cpp

example.java: example.ejava
erubis -bl java example.ejava > example.java

Expand All @@ -28,7 +31,7 @@ example.js: example.ejs

###----------

src = example.eruby example.ephp example.ec example.ejava example.escheme example.eperl example.ejs Makefile
src = example.eruby example.ephp example.ec example.ecpp example.ejava example.escheme example.eperl example.ejs Makefile

clean:
rm -f `ruby -e 'puts(Dir.glob("*.*") - %w[$(src)])'`
Expand All @@ -38,6 +41,7 @@ compile: example.bin example.class

example.bin: example.c
cc -o example.bin example.c
g++ -o example.bin2 example.cpp

example.class: example.java
jikes example.java
Expand All @@ -46,6 +50,7 @@ output: $(all) example.bin example.class
erubis example.eruby > example.ruby.out
php example.php > example.php.out
./example.bin '<aaa>' 'b&b' '"ccc"' > example.c.out
./example.bin2 '<aaa>' 'b&b' '"ccc"' > example.cpp.out
java example > example.javexample.bin
gosh example.scm > example.scm.out
# guile example.scm > example.scm.out
Expand Down
33 changes: 33 additions & 0 deletions examples/basic/example.ecpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<%
#include <string>
#include <iostream>
#include <sstream>

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

%>
<html>
<body>
<p>Hello <%= argv[0] %>!</p>
<table>
<tbody>
<% for (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;
}
%>

0 comments on commit 73a613b

Please sign in to comment.