From f8ef7e4a7c538bf392237c6c29caa9dedca6e29e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20Ankarstr=C3=B6m?= Date: Sat, 18 Sep 2021 02:25:16 +0200 Subject: Add README for mktpl --- README | 40 ++++++++++++++++++++-------------------- mktpl/README | 26 ++++++++++++++++++++++++++ t/front.t | 10 +++------- t/post.t | 16 ++++------------ 4 files changed, 53 insertions(+), 39 deletions(-) create mode 100644 mktpl/README 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 @@

<%= site.name %>

Latest posts

- <% - while(post = getpost(stmt, 0)){ - user = getuser(byid("users", post->user), 1); - %> + <% while(post = getpost(stmt, 0)){ + user = getuser(byid("users", post->user), 1); %> - <% - } - %> + <% } %>
id); %>"><%= post->subject %> user); %>"><%= user->name %> <% printdate(post->created); %>
<% #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 @@
 <%= post->text %>
 
-<% -if(attachment = getattachment(stmt, 0)){ -%> +<% if(attachment = getattachment(stmt, 0)){ %>

Attachments

- <% - do{ - %> + <% do{ %> - <% - }while(attachment = getattachment(stmt, 0)); - %> + <% }while(attachment = getattachment(stmt, 0)); %>
id); %>"><%= attachment->name %> <%= attachment->mime %> <%= attachment->description %>
-<% -} -%> +<% } %> <% #include "foot.tc" %> \ No newline at end of file -- cgit v1.2.3