How to create a clarion-like template engine

I am curious to learn what would be required to build a clarion-like template engine and maybe even try my hand at building one. I don’t mean a full application/dictionary editor like Clarion does, but just the template engine.

The engine would take as input:

  1. A bunch of symbols/variables (for example %File and related symbols), and
  2. Some template files (something like clarion .tpw).

The symbols could be read from a database or entered manually by some means.

The engine would then take the inputs and transform them into output files.

It seems to me that something like this is what Clarion does. Except of course that Clarion feeds the symbols from the application designer and the dictionary designer. I am interested in the template engine part only right now.

Do you have suggestions on how to do this? Thanks!

Basically you’d write a simple interpreter. Every line that starts with # is a command for the interpreter. All the other lines are output (with the % identifying tokens that need replacing.)

As programs go its not terribly complicated, but of course the strength of the system is in all the parts working together. The ability to embed for example is 90% of what makes it useful. The ability for one template to #AT another ones embed points is what makes it work.

1 Like

There is a product called ClaScript available at ClarionShop that is already available that does what you want. It is an interpreter written in Clarion that run scripts that look like Clarion. You can start with that and build any additional functionality you desire.

You can use EVALUATE('string') to do almost any calculation using the Variables form your program. You will have to BIND() them. In a similar you can use a VIEW() with ORDER('string') and FILTER('string') to read files Sorted or Filtered any dynamic way you want to specify as long as the you BIND() Variables and Files.