erubis-bmp 2.7.0.bmp
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CHANGES.txt +828 -0
- data/MIT-LICENSE +20 -0
- data/README.txt +10 -0
- data/benchmark/bench.rb +313 -0
- data/benchmark/bench_context.yaml +141 -0
- data/benchmark/mybench2.rb +266 -0
- data/benchmark/pibench.rb +163 -0
- data/benchmark/templates/_footer.html +4 -0
- data/benchmark/templates/_header.html +52 -0
- data/benchmark/templates/bench_erb.rhtml +29 -0
- data/benchmark/templates/bench_erubis.rhtml +29 -0
- data/benchmark/templates/bench_eruby.rhtml +29 -0
- data/bin/erubis +10 -0
- data/contrib/erubis-run.rb +132 -0
- data/doc/Rookbook.yaml +106 -0
- data/doc/docstyle.css +209 -0
- data/doc/users-guide.html +3551 -0
- data/doc/users-guide.txt +3631 -0
- data/examples/basic/Makefile +58 -0
- data/examples/basic/example.ec +42 -0
- data/examples/basic/example.ecpp +33 -0
- data/examples/basic/example.ejava +45 -0
- data/examples/basic/example.ejs +16 -0
- data/examples/basic/example.eperl +16 -0
- data/examples/basic/example.ephp +17 -0
- data/examples/basic/example.eruby +15 -0
- data/examples/basic/example.escheme +26 -0
- data/examples/pi-xhtml/ExamplePage.xhtml +80 -0
- data/examples/pi-xhtml/Makefile +17 -0
- data/examples/pi-xhtml/my/User.java +19 -0
- data/examples/pi-xhtml/my/Util.java +54 -0
- data/examples/pi/Makefile +54 -0
- data/examples/pi/example.ec +42 -0
- data/examples/pi/example.ejava +45 -0
- data/examples/pi/example.ejs +16 -0
- data/examples/pi/example.eperl +16 -0
- data/examples/pi/example.ephp +17 -0
- data/examples/pi/example.eruby +15 -0
- data/examples/pi/example.escheme +26 -0
- data/lib/erubis.rb +73 -0
- data/lib/erubis/context.rb +83 -0
- data/lib/erubis/converter.rb +357 -0
- data/lib/erubis/engine.rb +120 -0
- data/lib/erubis/engine/ec.rb +117 -0
- data/lib/erubis/engine/ecpp.rb +113 -0
- data/lib/erubis/engine/ejava.rb +110 -0
- data/lib/erubis/engine/ejavascript.rb +119 -0
- data/lib/erubis/engine/enhanced.rb +126 -0
- data/lib/erubis/engine/eperl.rb +95 -0
- data/lib/erubis/engine/ephp.rb +99 -0
- data/lib/erubis/engine/eruby.rb +125 -0
- data/lib/erubis/engine/escheme.rb +114 -0
- data/lib/erubis/engine/optimized.rb +127 -0
- data/lib/erubis/enhancer.rb +723 -0
- data/lib/erubis/error.rb +23 -0
- data/lib/erubis/evaluator.rb +88 -0
- data/lib/erubis/generator.rb +85 -0
- data/lib/erubis/helper.rb +47 -0
- data/lib/erubis/helpers/rails_form_helper.rb +197 -0
- data/lib/erubis/helpers/rails_helper.rb +353 -0
- data/lib/erubis/local-setting.rb +9 -0
- data/lib/erubis/main.rb +516 -0
- data/lib/erubis/preprocessing.rb +58 -0
- data/lib/erubis/tiny.rb +144 -0
- data/lib/erubis/util.rb +22 -0
- data/setup.rb +1331 -0
- data/test/Rookbook.yaml +42 -0
- data/test/assert-text-equal.rb +44 -0
- data/test/test-engines.rb +425 -0
- data/test/test-enhancers.rb +646 -0
- data/test/test-erubis.rb +887 -0
- data/test/test-index-cgi.rb +191 -0
- data/test/test-main.rb +752 -0
- data/test/test-users-guide.rb +73 -0
- data/test/test.rb +45 -0
- data/test/testutil.rb +111 -0
- metadata +121 -0
@@ -0,0 +1,58 @@
|
|
1
|
+
all = example.rb example.php example.c example.cpp example.java example.scm example.pl example.js
|
2
|
+
|
3
|
+
all: $(all)
|
4
|
+
|
5
|
+
example.rb: example.eruby
|
6
|
+
erubis -l ruby example.eruby > example.rb
|
7
|
+
|
8
|
+
|
9
|
+
example.php: example.ephp
|
10
|
+
erubis -l php example.ephp > example.php
|
11
|
+
|
12
|
+
example.c: example.ec
|
13
|
+
erubis -bl c example.ec > example.c
|
14
|
+
|
15
|
+
example.cpp: example.ecpp
|
16
|
+
erubis -bl cpp example.ecpp > example.cpp
|
17
|
+
|
18
|
+
example.java: example.ejava
|
19
|
+
erubis -bl java example.ejava > example.java
|
20
|
+
|
21
|
+
example.scm: example.escheme
|
22
|
+
erubis -l scheme --func=display example.escheme > example.scm
|
23
|
+
# erubis -l scheme example.escheme > example.scm
|
24
|
+
|
25
|
+
example.pl: example.eperl
|
26
|
+
erubis -l perl example.eperl > example.pl
|
27
|
+
|
28
|
+
example.js: example.ejs
|
29
|
+
erubis -l javascript example.ejs > example.js
|
30
|
+
|
31
|
+
|
32
|
+
###----------
|
33
|
+
|
34
|
+
src = example.eruby example.ephp example.ec example.ecpp example.ejava example.escheme example.eperl example.ejs Makefile
|
35
|
+
|
36
|
+
clean:
|
37
|
+
rm -f `ruby -e 'puts(Dir.glob("*.*") - %w[$(src)])'`
|
38
|
+
# rm -f $(all)
|
39
|
+
|
40
|
+
compile: example.bin example.class
|
41
|
+
|
42
|
+
example.bin: example.c
|
43
|
+
cc -o example.bin example.c
|
44
|
+
g++ -o example.bin2 example.cpp
|
45
|
+
|
46
|
+
example.class: example.java
|
47
|
+
jikes example.java
|
48
|
+
|
49
|
+
output: $(all) example.bin example.class
|
50
|
+
erubis example.eruby > example.ruby.out
|
51
|
+
php example.php > example.php.out
|
52
|
+
./example.bin '<aaa>' 'b&b' '"ccc"' > example.c.out
|
53
|
+
./example.bin2 '<aaa>' 'b&b' '"ccc"' > example.cpp.out
|
54
|
+
java example > example.javexample.bin
|
55
|
+
gosh example.scm > example.scm.out
|
56
|
+
# guile example.scm > example.scm.out
|
57
|
+
perl example.pl > example.pl.out
|
58
|
+
|
@@ -0,0 +1,42 @@
|
|
1
|
+
<%
|
2
|
+
#include <stdio.h>
|
3
|
+
|
4
|
+
void escape(char *str, FILE *out);
|
5
|
+
|
6
|
+
int main(int argc, char *argv[])
|
7
|
+
{
|
8
|
+
int i;
|
9
|
+
|
10
|
+
%>
|
11
|
+
<p>Hello <%== argv[0] %>!</p>
|
12
|
+
<table>
|
13
|
+
<tbody>
|
14
|
+
<% for (i = 1; i < argc; i++) { %>
|
15
|
+
<tr bgcolor="<%= i % 2 == 0 ? "#FFCCCC" : "#CCCCFF" %>">
|
16
|
+
<td><%= "%d", i %></td>
|
17
|
+
<td><%== argv[i] %></td>
|
18
|
+
</tr>
|
19
|
+
<% } %>
|
20
|
+
</tbody>
|
21
|
+
</table>
|
22
|
+
<%
|
23
|
+
|
24
|
+
return 0;
|
25
|
+
}
|
26
|
+
|
27
|
+
void escape(char *str, FILE *out)
|
28
|
+
{
|
29
|
+
char *pch;
|
30
|
+
for (pch = str; *pch != '\0'; pch++) {
|
31
|
+
switch (*pch) {
|
32
|
+
case '&': fputs("&", out); break;
|
33
|
+
case '>': fputs(">", out); break;
|
34
|
+
case '<': fputs("<", out); break;
|
35
|
+
case '"': fputs(""", out); break;
|
36
|
+
case '\'': fputs("'", out); break;
|
37
|
+
default: fputc(*pch, out);
|
38
|
+
}
|
39
|
+
}
|
40
|
+
}
|
41
|
+
|
42
|
+
%>
|
@@ -0,0 +1,33 @@
|
|
1
|
+
<%
|
2
|
+
#include <string>
|
3
|
+
#include <iostream>
|
4
|
+
#include <sstream>
|
5
|
+
|
6
|
+
int main(int argc, char *argv[])
|
7
|
+
{
|
8
|
+
int i;
|
9
|
+
std::stringstream _buf;
|
10
|
+
|
11
|
+
%>
|
12
|
+
<html>
|
13
|
+
<body>
|
14
|
+
<p>Hello <%= argv[0] %>!</p>
|
15
|
+
<table>
|
16
|
+
<tbody>
|
17
|
+
<% for (i = 1; i < argc; i++) { %>
|
18
|
+
<tr bgcolor="<%= i % 2 == 0 ? "#FFCCCC" : "#CCCCFF" %>">
|
19
|
+
<td><%= i %></td>
|
20
|
+
<td><%= argv[i] %></td>
|
21
|
+
</tr>
|
22
|
+
<% } %>
|
23
|
+
</tbody>
|
24
|
+
</table>
|
25
|
+
</body>
|
26
|
+
</html>
|
27
|
+
<%
|
28
|
+
|
29
|
+
std::string _output = _buf.str();
|
30
|
+
std::cout << _output;
|
31
|
+
return 0;
|
32
|
+
}
|
33
|
+
%>
|
@@ -0,0 +1,45 @@
|
|
1
|
+
<%
|
2
|
+
import java.util.*;
|
3
|
+
|
4
|
+
public class example {
|
5
|
+
|
6
|
+
public static void main(String[] args) {
|
7
|
+
String user = "Erubis";
|
8
|
+
String[] list = { "<aaa>", "b&b", "\"ccc\"" };
|
9
|
+
StringBuffer _buf = new StringBuffer();
|
10
|
+
%>
|
11
|
+
<p>Hello <%== user %>!</p>
|
12
|
+
<table>
|
13
|
+
<tbody>
|
14
|
+
<% for (int i = 0; i < list.length; i++) { %>
|
15
|
+
<tr bgcolor="<%= i % 2 == 0 ? "#FFCCCC" : "#CCCCFF" %>">
|
16
|
+
<td><%= i + 1 %></td>
|
17
|
+
<td><%== list[i] %></td>
|
18
|
+
</tr>
|
19
|
+
<% } %>
|
20
|
+
</tbody>
|
21
|
+
</table>
|
22
|
+
<%
|
23
|
+
System.out.print(_buf.toString());
|
24
|
+
}
|
25
|
+
|
26
|
+
public static String escape(String s) {
|
27
|
+
StringBuffer sb = new StringBuffer();
|
28
|
+
for (int i = 0; i < s.length(); i++) {
|
29
|
+
char ch = s.charAt(i);
|
30
|
+
switch (ch) {
|
31
|
+
case '<': sb.append("<"); break;
|
32
|
+
case '>': sb.append(">"); break;
|
33
|
+
case '&': sb.append("&"); break;
|
34
|
+
case '"': sb.append("""); break;
|
35
|
+
default: sb.append(ch);
|
36
|
+
}
|
37
|
+
}
|
38
|
+
return sb.toString();
|
39
|
+
}
|
40
|
+
|
41
|
+
public static String escape(int i) {
|
42
|
+
return Integer.toString(i);
|
43
|
+
}
|
44
|
+
}
|
45
|
+
%>
|
@@ -0,0 +1,16 @@
|
|
1
|
+
<%
|
2
|
+
var user = 'Erubis';
|
3
|
+
var list = ['<aaa>', 'b&b', '"ccc"'];
|
4
|
+
%>
|
5
|
+
<p>Hello <%= user %>!</p>
|
6
|
+
<table>
|
7
|
+
<tbody>
|
8
|
+
<% var i; %>
|
9
|
+
<% for (i = 0; i < list.length; i++) { %>
|
10
|
+
<tr bgcolor="<%= i % 2 == 0 ? '#FFCCCC' : '#CCCCFF' %>">
|
11
|
+
<td><%= i + 1 %></td>
|
12
|
+
<td><%= list[i] %></td>
|
13
|
+
</tr>
|
14
|
+
<% } %>
|
15
|
+
</tbody>
|
16
|
+
</table>
|
@@ -0,0 +1,16 @@
|
|
1
|
+
<%
|
2
|
+
my $user = 'Erubis';
|
3
|
+
my @list = ('<aaa>', 'b&b', '"ccc"');
|
4
|
+
%>
|
5
|
+
<p>Hello <%== $user %>!</p>
|
6
|
+
<table>
|
7
|
+
<tbody>
|
8
|
+
<% $i = 0; %>
|
9
|
+
<% for $item (@list) { %>
|
10
|
+
<tr bgcolor=<%= ++$i % 2 == 0 ? '#FFCCCC' : '#CCCCFF' %>">
|
11
|
+
<td><%= $i %></td>
|
12
|
+
<td><%== $item %></td>
|
13
|
+
</tr>
|
14
|
+
<% } %>
|
15
|
+
</tbody>
|
16
|
+
</table>
|
@@ -0,0 +1,17 @@
|
|
1
|
+
<%
|
2
|
+
$user = "World";
|
3
|
+
$list = array('<aaa>', 'b&b', '"ccc"');
|
4
|
+
%>
|
5
|
+
<p>Hello <%= $user %>!</p>
|
6
|
+
<table>
|
7
|
+
<tbody>
|
8
|
+
<% $i = 0 %>
|
9
|
+
<% foreach ($list as $item) { %>
|
10
|
+
<% $i++; %>
|
11
|
+
<tr bgcolor="<%= $i % 2 == 0 ? '#FFCCCC' : '#CCCCFF' %>">
|
12
|
+
<td><%= $i %></td>
|
13
|
+
<td><%== $item %></td>
|
14
|
+
</tr>
|
15
|
+
<% } %>
|
16
|
+
</tbody>
|
17
|
+
</table>
|
@@ -0,0 +1,15 @@
|
|
1
|
+
<%
|
2
|
+
user = 'Erubis'
|
3
|
+
list = ['<aaa>', 'b&b', '"ccc"']
|
4
|
+
%>
|
5
|
+
<p>Hello <%= user %>!</p>
|
6
|
+
<table>
|
7
|
+
<tbody>
|
8
|
+
<% list.each_with_index do |item, i| %>
|
9
|
+
<tr bgcolor="<%= i % 2 == 0 ? '#FFCCCC' : '#CCCCFF' %>">
|
10
|
+
<td><%= i + 1 %></td>
|
11
|
+
<td><%== item %></td>
|
12
|
+
</tr>
|
13
|
+
<% end %>
|
14
|
+
</tbody>
|
15
|
+
</table>
|
@@ -0,0 +1,26 @@
|
|
1
|
+
<%
|
2
|
+
(let ((user "Erubis")
|
3
|
+
(items '("<aaa>" "b&b" "\"ccc\""))
|
4
|
+
(i 0))
|
5
|
+
%>
|
6
|
+
<p>Hello <%= user %>!</p>
|
7
|
+
<table>
|
8
|
+
<tbody>
|
9
|
+
<%
|
10
|
+
(for-each
|
11
|
+
(lambda (item)
|
12
|
+
(set! i (+ i 1))
|
13
|
+
%>
|
14
|
+
<tr bgcolor="<%= (if (= (modulo i 2) 0) "#FFCCCC" "#CCCCFF") %>">
|
15
|
+
<td><%= i %></td>
|
16
|
+
<td><%= item %></td>
|
17
|
+
</tr>
|
18
|
+
<%
|
19
|
+
) ; lambda end
|
20
|
+
items) ; for-each end
|
21
|
+
%>
|
22
|
+
</tbody>
|
23
|
+
</table>
|
24
|
+
<%
|
25
|
+
) ; let end
|
26
|
+
%>
|
@@ -0,0 +1,80 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
|
3
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
4
|
+
<?java-header
|
5
|
+
//package my;
|
6
|
+
|
7
|
+
import java.util.*;
|
8
|
+
|
9
|
+
import my.User;
|
10
|
+
import static my.Util.escapeXml;
|
11
|
+
|
12
|
+
public class ExamplePage {
|
13
|
+
|
14
|
+
private String title = "Users list";
|
15
|
+
private List<User> users;
|
16
|
+
|
17
|
+
public ExamplePage(List<User> users) {
|
18
|
+
this.users = users;
|
19
|
+
}
|
20
|
+
|
21
|
+
public String createView() {
|
22
|
+
StringBuilder _buf = new StringBuilder();
|
23
|
+
?>
|
24
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
25
|
+
<head>
|
26
|
+
<title>${title}</title>
|
27
|
+
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
28
|
+
</head>
|
29
|
+
<body>
|
30
|
+
<h1>${title}</h1>
|
31
|
+
|
32
|
+
<table>
|
33
|
+
<?java
|
34
|
+
int i = 0;
|
35
|
+
for (User user: users) {
|
36
|
+
String color = ++i % 2 == 0 ? "#FFCCCC" : "#CCCCFF";
|
37
|
+
?>
|
38
|
+
<tr bgcolor="$!{color}">
|
39
|
+
<td>${user.getName()}</td>
|
40
|
+
<td>${user.getEmail()}</td>
|
41
|
+
</tr>
|
42
|
+
<?java
|
43
|
+
}
|
44
|
+
?>
|
45
|
+
<?java /***** ?>
|
46
|
+
<tr class="odd">
|
47
|
+
<td>foo</td>
|
48
|
+
<td>foo@mail.com</td>
|
49
|
+
</tr>
|
50
|
+
<tr class="even">
|
51
|
+
<td>bar</td>
|
52
|
+
<td>bar@mail.org</td>
|
53
|
+
</tr>
|
54
|
+
<?java *****/ ?>
|
55
|
+
</table>
|
56
|
+
|
57
|
+
</body>
|
58
|
+
</html>
|
59
|
+
<?java-footer
|
60
|
+
return _buf.toString();
|
61
|
+
}//createView()
|
62
|
+
|
63
|
+
|
64
|
+
public static void main(String[] args) {
|
65
|
+
// create users list
|
66
|
+
List<User> users = new ArrayList<User>();
|
67
|
+
users.add(new User("<aaa>", "aaa@mail.com"));
|
68
|
+
users.add(new User("b&b", "bbb@mail.net"));
|
69
|
+
users.add(new User("\"ccc\"", "ccc@mail.org"));
|
70
|
+
|
71
|
+
// create users page
|
72
|
+
ExamplePage page = new ExamplePage(users);
|
73
|
+
|
74
|
+
// print page
|
75
|
+
System.out.print(page.createView());
|
76
|
+
}//main()
|
77
|
+
|
78
|
+
|
79
|
+
}//class
|
80
|
+
?>
|
@@ -0,0 +1,17 @@
|
|
1
|
+
.SUFFIXES: .class .java .xhtml
|
2
|
+
|
3
|
+
T = ExamplePage
|
4
|
+
|
5
|
+
execute: $T.class
|
6
|
+
java $T
|
7
|
+
|
8
|
+
.java.class:
|
9
|
+
javac -source 1.5 $<
|
10
|
+
|
11
|
+
$T.java: $T.xhtml
|
12
|
+
erubis -bxl java --pi=java --escapefunc='escapeXml' $< > $@
|
13
|
+
|
14
|
+
|
15
|
+
clean:
|
16
|
+
rm -f $T.java $T.class my/*.class
|
17
|
+
|
@@ -0,0 +1,19 @@
|
|
1
|
+
package my;
|
2
|
+
|
3
|
+
public class User {
|
4
|
+
|
5
|
+
private String name;
|
6
|
+
private String email;
|
7
|
+
|
8
|
+
public User(String name, String email) {
|
9
|
+
this.name = name;
|
10
|
+
this.email = email;
|
11
|
+
}
|
12
|
+
|
13
|
+
public String getName() { return name; }
|
14
|
+
public void setName(String name) { this.name = name; }
|
15
|
+
public String getEmail() { return email; }
|
16
|
+
public void setEmail(String email) { this.email = email; }
|
17
|
+
|
18
|
+
}
|
19
|
+
|
@@ -0,0 +1,54 @@
|
|
1
|
+
package my;
|
2
|
+
|
3
|
+
public class Util {
|
4
|
+
|
5
|
+
public static String escapeXml(String s) {
|
6
|
+
if (s == null) return "";
|
7
|
+
StringBuilder sb = new StringBuilder();
|
8
|
+
int len = s.length();
|
9
|
+
for (int i = 0; i < len; i++) {
|
10
|
+
char ch = s.charAt(i);
|
11
|
+
switch (ch) {
|
12
|
+
case '<': sb.append("<"); break;
|
13
|
+
case '>': sb.append(">"); break;
|
14
|
+
case '&': sb.append("&"); break;
|
15
|
+
case '"': sb.append("""); break;
|
16
|
+
default: sb.append(ch);
|
17
|
+
}
|
18
|
+
}
|
19
|
+
return sb.toString();
|
20
|
+
}
|
21
|
+
|
22
|
+
public static String escapeXml(Object obj) {
|
23
|
+
return escapeXml(obj.toString());
|
24
|
+
}
|
25
|
+
|
26
|
+
|
27
|
+
public static String checked(boolean cond) {
|
28
|
+
return cond ? " checked=\"checked\"" : "";
|
29
|
+
}
|
30
|
+
|
31
|
+
public static String selected(boolean cond) {
|
32
|
+
return cond ? " selected=\"selected\"" : "";
|
33
|
+
}
|
34
|
+
|
35
|
+
public static String disabled(boolean cond) {
|
36
|
+
return cond ? " disabled=\"disabled\"" : "";
|
37
|
+
}
|
38
|
+
|
39
|
+
|
40
|
+
public static String nl2br(String str) {
|
41
|
+
StringBuilder sb = new StringBuilder();
|
42
|
+
int len = str.length();
|
43
|
+
for (int i = 0; i < len; i++) {
|
44
|
+
char ch = str.charAt(i);
|
45
|
+
if (ch == '\n') {
|
46
|
+
sb.append("<br />\n");
|
47
|
+
} else {
|
48
|
+
sb.append(ch);
|
49
|
+
}
|
50
|
+
}
|
51
|
+
return sb.toString();
|
52
|
+
}
|
53
|
+
|
54
|
+
}
|