Jump to content
Sign in to follow this  
darnocian

Sempare Template Engine 1.7.7

Recommended Posts

Posted (edited)

Hi All,

 

Just a quick ping that an update to the Sempare Template Engine is now available... v1.7.7

 

It is also available on GetIt. Please star the project if you havn't already. (Thanks)

 

Also for those watching Delphi Dev Days (https://www.codegear.com/DevDaysofSummer/) ... There will be a video posted today (15 Aug) with some demos showing some features and how easily the template engine can be included into projects...

 

https://github.com/sempare/sempare-delphi-template-engine

 

Changes:

- fixed a few things

- new 'functional includes' syntatic sugar

- release mode builds will fail if the license confirmation is not acknowledged 

- also fully CI enabled now on github

 

... what is a functional include...

 

Lets say we have a main template where we are creating an html form:

<form method=post action=/register>
    Name: <input name=name>
    E-mail: <input name=email>
    <input type=submit value=register>
</form>

 

so what we could do from a templating perspective:

<% template 'input' %>
    <% label %>: <input name=<% name %>>
<% end %>

<% template 'button' %>
    <% label %>: <input type=<% type %>>
<% end %>

<form method=post action=/register>
    <% input { label="Name", name="name" } %>
    <% input { label="E-mail", name="email" } %>
    <% button { label="register", type="submit" } %>
</form>

 

So above, you can see that we can have 'inline templates' that are named 'input' and 'button'. In the form section, the 'functional include' syntax is then used to pass the params...

 

The alternative way of doing the include traditionally is a bit more verbose, but essentially the same:

<form method=post action=/register>
    <% include 'input', { "label": "Name", "name": "name" } %>
    <% include 'input', { "label": "E-mail", "name": "email" } %>
    <% include 'button', { "label": "register", "type": "submit" } %>
</form>

 

The above is a bit more verbose, passing a dictionary, whereas the 'functional include' syntax can be a bit more pretty on the eye...

 

So the nice thing then is that the inline templates could be moved out to separate files. The template registry can then be configured to load the various templates as required - from disk, resources, db, etc... Custom styling, etc can then be localised to the specific 'atomic' template. This works quite nicely when using stuff like TailwindCSS (https://tailwindcss.com/) , which lends itself to styles being inline rather than being in CSS files...

 

Anyways, have fun. Please support me if you can.

 

 

 

 

Edited by darnocian
  • Like 2

Share this post


Link to post

Hi all,

 

For any users, or anyone interested in the template engine, I would love to get some feedback from you to help with next steps in development on the project. The questionnaire is a bit general, as the objective is to guide the direction of this project and another I will be releasing soon as well.

 

https://docs.google.com/forms/d/e/1FAIpQLScioIiDxvsWK01fMFqYr9aJ6KhCGeiw4UaU_esGuztEE7vYwA/viewform

 

Thank you in advance.

 

Regards,

Conrad

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×