aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README40
-rw-r--r--mktpl/README26
-rw-r--r--t/front.t10
-rw-r--r--t/post.t16
4 files changed, 53 insertions, 39 deletions
diff --git a/README b/README
index 12f83fc..4266c7f 100644
--- a/README
+++ b/README
@@ -5,24 +5,24 @@ SQLite as its database. It is designed to be a simple, fast and
reliable alternative to software like phpBB. Written in portable
C89, it can be run on practically any UNIX system.
-`cforum' is also small:
+It is also rather small.
- $ wc -l *.c *.h t/*.t */*.lex
- 96 cforum.c
- 96 ctl.c
- 121 db.c
- 12 err.c
- 106 query.c
- 3 ctl.h
- 34 db.h
- 0 err.h
- 14 query.h
- 2 site.h
- 3 t/err.t
- 1 t/foot.t
- 17 t/front.t
- 6 t/head.t
- 35 t/post.t
- 2 t/user.t
- 86 mktpl/mktpl.lex
- 634 total
+wc -l *.c *.h */*.t */*.lex
+ 96 cforum.c
+ 96 ctl.c
+ 121 db.c
+ 12 err.c
+ 106 query.c
+ 3 ctl.h
+ 34 db.h
+ 0 err.h
+ 14 query.h
+ 2 site.h
+ 3 t/err.t
+ 1 t/foot.t
+ 13 t/front.t
+ 6 t/head.t
+ 27 t/post.t
+ 2 t/user.t
+ 87 mktpl/mktpl.lex
+ 623 total
diff --git a/mktpl/README b/mktpl/README
new file mode 100644
index 0000000..85a2fe3
--- /dev/null
+++ b/mktpl/README
@@ -0,0 +1,26 @@
+ README
+
+`mktpl' is a simple UNIX program that compiles template files (.t)
+to C files (.tc). Template files support special syntax (<% ... %>)
+that may contain C code.
+
+For example, the template
+
+ This will be printed.
+ <%
+ /* This C code will be executed. */
+ for(i = 0; i<10; i++) printf("Hello World!\n");
+ strcpy(s, "This");
+ %>
+ <%= s %> will be evaluated and printed as a string.
+
+is compiled to the following C code:
+
+ printf("This will be printed.\n ");
+ /* This C code will be executed. */
+ for(i = 0; i<10; i++) printf("Hello World!\n");
+ strcpy(s, "This");
+
+ printf("\n");
+ printf("%s", s );
+ printf(" will be evaluated and printed as a string.");
diff --git a/t/front.t b/t/front.t
index 5c88166..fcdecdb 100644
--- a/t/front.t
+++ b/t/front.t
@@ -2,17 +2,13 @@
<h1><%= site.name %></h1>
<h3>Latest posts</h3>
<table border="1">
- <%
- while(post = getpost(stmt, 0)){
- user = getuser(byid("users", post->user), 1);
- %>
+ <% while(post = getpost(stmt, 0)){
+ user = getuser(byid("users", post->user), 1); %>
<tr>
<td><a href="?post=<% printf("%d", post->id); %>"><%= post->subject %></a></td>
<td><a href="?user=<% printf("%d", post->user); %>"><%= user->name %></a></td>
<td><% printdate(post->created); %></td>
</tr>
- <%
- }
- %>
+ <% } %>
</table>
<% #include "foot.tc" %> \ No newline at end of file
diff --git a/t/post.t b/t/post.t
index deeb285..549b4ec 100644
--- a/t/post.t
+++ b/t/post.t
@@ -13,24 +13,16 @@
<pre>
<%= post->text %>
</pre>
-<%
-if(attachment = getattachment(stmt, 0)){
-%>
+<% if(attachment = getattachment(stmt, 0)){ %>
<h3>Attachments</h3>
<table border="1">
- <%
- do{
- %>
+ <% do{ %>
<tr>
<td><a href="?attachment=<% printf("%d", attachment->id); %>"><%= attachment->name %></a></td>
<td><%= attachment->mime %></td>
<td><%= attachment->description %></td>
</tr>
- <%
- }while(attachment = getattachment(stmt, 0));
- %>
+ <% }while(attachment = getattachment(stmt, 0)); %>
</table>
-<%
-}
-%>
+<% } %>
<% #include "foot.tc" %> \ No newline at end of file