Update Vendored Erubis to 2.6.6

This commit is contained in:
Jacques Distler 2010-07-04 08:51:53 -05:00
parent c18c2f988d
commit 39c2138f88
300 changed files with 207 additions and 171 deletions

View file

@ -0,0 +1,53 @@
all = example.rb example.php example.c example.java example.scm example.pl example.js
all: $(all)
example.rb: example.eruby
erubis -l ruby example.eruby > example.rb
example.php: example.ephp
erubis -l php example.ephp > example.php
example.c: example.ec
erubis -bl c example.ec > example.c
example.java: example.ejava
erubis -bl java example.ejava > example.java
example.scm: example.escheme
erubis -l scheme --func=display example.escheme > example.scm
# erubis -l scheme example.escheme > example.scm
example.pl: example.eperl
erubis -l perl example.eperl > example.pl
example.js: example.ejs
erubis -l javascript example.ejs > example.js
###----------
src = example.eruby example.ephp example.ec example.ejava example.escheme example.eperl example.ejs Makefile
clean:
rm -f `ruby -e 'puts(Dir.glob("*.*") - %w[$(src)])'`
# rm -f $(all)
compile: example.bin example.class
example.bin: example.c
cc -o example.bin example.c
example.class: example.java
jikes example.java
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
java example > example.javexample.bin
gosh example.scm > example.scm.out
# guile example.scm > example.scm.out
perl example.pl > example.pl.out

View file

@ -0,0 +1,42 @@
<%
#include <stdio.h>
void escape(char *str, FILE *out);
int main(int argc, char *argv[])
{
int i;
%>
<p>Hello <%== argv[0] %>!</p>
<table>
<tbody>
<% for (i = 1; i < argc; i++) { %>
<tr bgcolor="<%= i % 2 == 0 ? "#FFCCCC" : "#CCCCFF" %>">
<td><%= "%d", i %></td>
<td><%== argv[i] %></td>
</tr>
<% } %>
</tbody>
</table>
<%
return 0;
}
void escape(char *str, FILE *out)
{
char *pch;
for (pch = str; *pch != '\0'; pch++) {
switch (*pch) {
case '&': fputs("&amp;", out); break;
case '>': fputs("&gt;", out); break;
case '<': fputs("&lt;", out); break;
case '"': fputs("&quot;", out); break;
case '\'': fputs("&#039;", out); break;
default: fputc(*pch, out);
}
}
}
%>

View file

@ -0,0 +1,45 @@
<%
import java.util.*;
public class example {
public static void main(String[] args) {
String user = "Erubis";
String[] list = { "<aaa>", "b&b", "\"ccc\"" };
StringBuffer _buf = new StringBuffer();
%>
<p>Hello <%== user %>!</p>
<table>
<tbody>
<% for (int i = 0; i < list.length; i++) { %>
<tr bgcolor="<%= i % 2 == 0 ? "#FFCCCC" : "#CCCCFF" %>">
<td><%= i + 1 %></td>
<td><%== list[i] %></td>
</tr>
<% } %>
</tbody>
</table>
<%
System.out.print(_buf.toString());
}
public static String escape(String s) {
StringBuffer sb = new StringBuffer();
for (int i = 0; i < s.length(); i++) {
char ch = s.charAt(i);
switch (ch) {
case '<': sb.append("&lt;"); break;
case '>': sb.append("&gt;"); break;
case '&': sb.append("&amp;"); break;
case '"': sb.append("&quot;"); break;
default: sb.append(ch);
}
}
return sb.toString();
}
public static String escape(int i) {
return Integer.toString(i);
}
}
%>

View file

@ -0,0 +1,16 @@
<%
var user = 'Erubis';
var list = ['<aaa>', 'b&b', '"ccc"'];
%>
<p>Hello <%= user %>!</p>
<table>
<tbody>
<% var i; %>
<% for (i = 0; i < list.length; i++) { %>
<tr bgcolor="<%= i % 2 == 0 ? '#FFCCCC' : '#CCCCFF' %>">
<td><%= i + 1 %></td>
<td><%= list[i] %></td>
</tr>
<% } %>
</tbody>
</table>

View file

@ -0,0 +1,16 @@
<%
my $user = 'Erubis';
my @list = ('<aaa>', 'b&b', '"ccc"');
%>
<p>Hello <%== $user %>!</p>
<table>
<tbody>
<% $i = 0; %>
<% for $item (@list) { %>
<tr bgcolor=<%= ++$i % 2 == 0 ? '#FFCCCC' : '#CCCCFF' %>">
<td><%= $i %></td>
<td><%== $item %></td>
</tr>
<% } %>
</tbody>
</table>

View file

@ -0,0 +1,17 @@
<%
$user = "World";
$list = array('<aaa>', 'b&b', '"ccc"');
%>
<p>Hello <%= $user %>!</p>
<table>
<tbody>
<% $i = 0 %>
<% foreach ($list as $item) { %>
<% $i++; %>
<tr bgcolor="<%= $i % 2 == 0 ? '#FFCCCC' : '#CCCCFF' %>">
<td><%= $i %></td>
<td><%== $item %></td>
</tr>
<% } %>
</tbody>
</table>

View file

@ -0,0 +1,15 @@
<%
user = 'Erubis'
list = ['<aaa>', 'b&b', '"ccc"']
%>
<p>Hello <%= user %>!</p>
<table>
<tbody>
<% list.each_with_index do |item, i| %>
<tr bgcolor="<%= i % 2 == 0 ? '#FFCCCC' : '#CCCCFF' %>">
<td><%= i + 1 %></td>
<td><%== item %></td>
</tr>
<% end %>
</tbody>
</table>

View file

@ -0,0 +1,26 @@
<%
(let ((user "Erubis")
(items '("<aaa>" "b&b" "\"ccc\""))
(i 0))
%>
<p>Hello <%= user %>!</p>
<table>
<tbody>
<%
(for-each
(lambda (item)
(set! i (+ i 1))
%>
<tr bgcolor="<%= (if (= (modulo i 2) 0) "#FFCCCC" "#CCCCFF") %>">
<td><%= i %></td>
<td><%= item %></td>
</tr>
<%
) ; lambda end
items) ; for-each end
%>
</tbody>
</table>
<%
) ; let end
%>

View file

@ -0,0 +1,54 @@
all = example.rb example.php example.c example.java example.scm example.pl example.js
all: $(all)
example.rb: example.eruby
erubis --pi -l ruby example.eruby > example.rb
example.php: example.ephp
erubis --pi -l php example.ephp > example.php
example.c: example.ec
erubis --pi -bl c example.ec > example.c
example.java: example.ejava
erubis --pi -bl java example.ejava > example.java
example.scm: example.escheme
erubis --pi -l scheme --func=display example.escheme > example.scm
# erubis --pi -l scheme example.escheme > example.scm
example.pl: example.eperl
erubis --pi -l perl example.eperl > example.pl
example.js: example.ejs
erubis --pi -l javascript example.ejs > example.js
###----------
src = example.eruby example.ephp example.ec example.ejava example.escheme example.eperl example.ejs Makefile
clean:
rm -f `ruby -e 'puts(Dir.glob("*.*") - %w[$(src)])'`
# rm -f $(all)
compile: example.bin example.class
example.bin: example.c
cc -o example.bin example.c
example.class: example.java
jikes example.java
output: $(all) example.bin example.class
erubis --pi example.eruby > example.ruby.result
#ruby example.rb > example.ruby.result
php example.php > example.php.result
./example.bin '<aaa>' 'b&b' '"ccc"' > example.c.result
java example > example.java.result
gosh example.scm > example.scm.result
#guile example.scm > example.scm.result
perl example.pl > example.pl.result

View file

@ -0,0 +1,42 @@
<?c
#include <stdio.h>
void escape(char *str, FILE *out);
int main(int argc, char *argv[])
{
int i;
?>
<p>Hello @!{argv[0]}@!</p>
<table>
<tbody>
<?c for (i = 1; i < argc; i++) { ?>
<tr bgcolor="@{i % 2 == 0 ? "#FFCCCC" : "#CCCCFF"}@">
<td>@!{"%d", i}@</td>
<td>@{argv[i]}@</td>
</tr>
<?c } ?>
</tbody>
</table>
<?c
return 0;
}
void escape(char *str, FILE *out)
{
char *pch;
for (pch = str; *pch != '\0'; pch++) {
switch (*pch) {
case '&': fputs("&amp;", out); break;
case '>': fputs("&gt;", out); break;
case '<': fputs("&lt;", out); break;
case '"': fputs("&quot;", out); break;
case '\'': fputs("&#039;", out); break;
default: fputc(*pch, out);
}
}
}
?>

View file

@ -0,0 +1,45 @@
<?java
import java.util.*;
public class example {
public static void main(String[] args) {
String user = "Erubis";
String[] list = { "<aaa>", "b&b", "\"ccc\"" };
StringBuffer _buf = new StringBuffer();
?>
<p>Hello @{user}@!</p>
<table>
<tbody>
<?java for (int i = 0; i < list.length; i++) { ?>
<tr bgcolor="@{i % 2 == 0 ? "#FFCCCC" : "#CCCCFF"}@">
<td>@!{i + 1}@</td>
<td>@{list[i]}@</td>
</tr>
<?java } ?>
</tbody>
</table>
<?java
System.out.print(_buf.toString());
}
public static String escape(String s) {
StringBuffer sb = new StringBuffer();
for (int i = 0; i < s.length(); i++) {
char ch = s.charAt(i);
switch (ch) {
case '<': sb.append("&lt;"); break;
case '>': sb.append("&gt;"); break;
case '&': sb.append("&amp;"); break;
case '"': sb.append("&quot;"); break;
default: sb.append(ch);
}
}
return sb.toString();
}
public static String escape(int i) {
return Integer.toString(i);
}
}
?>

View file

@ -0,0 +1,16 @@
<?js
var user = 'Erubis';
var list = ['<aaa>', 'b&b', '"ccc"'];
?>
<p>Hello @{user}@!</p>
<table>
<tbody>
<?js var i; ?>
<?js for (i = 0; i < list.length; i++) { ?>
<tr bgcolor="@{i % 2 == 0 ? '#FFCCCC' : '#CCCCFF'}@">
<td>@{i + 1}@</td>
<td>@{list[i]}@</td>
</tr>
<?js } ?>
</tbody>
</table>

View file

@ -0,0 +1,16 @@
<?perl
my $user = 'Erubis';
my @list = ('<aaa>', 'b&b', '"ccc"');
?>
<p>Hello @{$user}@!</p>
<table>
<tbody>
<?perl $i = 0; ?>
<?perl for $item (@list) { ?>
<tr bgcolor=@!{++$i % 2 == 0 ? '#FFCCCC' : '#CCCCFF'}@">
<td>@!{$i}@</td>
<td>@{$item}@</td>
</tr>
<?perl } ?>
</tbody>
</table>

View file

@ -0,0 +1,17 @@
<?php
$user = "World";
$list = array('<aaa>', 'b&b', '"ccc"');
?>
<p>Hello @{$user}@!</p>
<table>
<tbody>
<?php $i = 0 ?>
<?php foreach ($list as $item) { ?>
<?php $i++; ?>
<tr bgcolor="@!{$i % 2 == 0 ? '#FFCCCC' : '#CCCCFF'}@">
<td>@!{$i}@</td>
<td>@{$item}@</td>
</tr>
<?php } ?>
</tbody>
</table>

View file

@ -0,0 +1,15 @@
<?rb
user = 'Erubis'
list = ['<aaa>', 'b&b', '"ccc"']
?>
<p>Hello @{user}@!</p>
<table>
<tbody>
<?rb list.each_with_index do |item, i| ?>
<tr bgcolor="@!{i % 2 == 0 ? '#FFCCCC' : '#CCCCFF'}@">
<td>@!{i + 1}@</td>
<td>@{item}@</td>
</tr>
<?rb end ?>
</tbody>
</table>

View file

@ -0,0 +1,26 @@
<?scheme
(let ((user "Erubis")
(items '("<aaa>" "b&b" "\"ccc\""))
(i 0))
?>
<p>Hello @!{user}@!</p>
<table>
<tbody>
<?scheme
(for-each
(lambda (item)
(set! i (+ i 1))
?>
<tr bgcolor="@!{(if (= (modulo i 2) 0) "#FFCCCC" "#CCCCFF")}@">
<td>@!{i}@</td>
<td>@!{item}@</td>
</tr>
<?scheme
) ; lambda end
items) ; for-each end
?>
</tbody>
</table>
<?scheme
) ; let end
?>