Skip to content

San7o/micro-templating.c

Repository files navigation

micro-templating.c
==================

A simple tool to generate a file from a template, in ~200 lines of
code.

Author:  Giovanni Santini
Mail:    [email protected]
License: MIT


Compile
-------

   cc micro-templating.c -o micro-templating

Or run `make`


Example
-------

Here is an example template:

  <p>Here is a generated list!</p>
  <ul>
    %{ for(int i = 0; i < 10; ++i) { }%
      <li> Item number %{ INT(i); }% </li>
    %{ } }%
  </ul>

You can put C code between "%{" and "}%". Running micro-templating
over this template will generate a new C file with the specified
output name plus the ".c" extension. When compiled and executed, it
will generate the final output file.

  ./micro-templating
  Usage: ./micro-templating <template-file> <output-file>

  ./micro-templating example.template example.html
  gcc example.html.c -o example
  ./example

The output would look like this:

   <p>Here is a generated list!</p>
   <ul>
     <li> Item number 0 </li>  
     <li> Item number 1 </li>
     <li> Item number 2 </li>
     <li> Item number 3 </li>
      ...
   </ul>

About

A simple tool to generate a file from a template, in ~200 lines of code.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published