Off how simple fixes teach you something new


So I picked a small fixed because I assumed i could do a good thing with HTML, and JavaScript.

Boy was I wrong.

Today I learned about smarty,

What is smarty you say well its a template engine, for PHP in theory is a way to separate logic and content from presentation.(very similar to how MIC is in theory managed I believe.

In concept this is simple you just do some HTML front end and manage the information you need sent externally, say in this case a table, the information, such as headers and information are internal to the system I am able to cycle through them and get all I need directly from the system.

So in this project which I am gonna continue contributing assuming Its the beginning of a more complex accounting system- which was my goal when looking at it. As the system is very thread bare -one of the reasons I believe this project will continue to grow.

How do we envision this template to work in theory?

Well in this system my idea is
I get passed or declare a list of headers within the system

a simple array even so say
string headers[] = {“ID”,”Name”,” Summary”}

then i can just call syntax and loop through head
<thead>
<tr>

{foreach $ head as $head}

  		<th>{$head}</th>
	{/foreach}

</thead>


I did however not get a complete overview as this was a simple class of making a simple bootstrap system for the information displayed and I didn’t want to mess with the current settings of the project that’s clearly on infancy, but I found interesting, just because it seemed like a small concept was snowballing into something I didn’t expect so in lieu of my pull being a bit short I’m gonna make it up by having a good time writing about Smarty

as stated before this is a system that is aiming to separate business layer and presentation, this means template files are only using logic for presentation, binding data building tales upper casing including templates etc

– the aim however is lost if user doesn’t use it as intended as smarty does not enforce the layer separation,

what are the advantages, in general is fast-similar how vue.js(https://vuejs.org/ A topic for another day however) is focused to speed and lean, its meant to show data and only recompiled if needed has functions and variable modifiers, else if , loops cache functions nesting, inheritance, and plugins.

In general is a solution for templates as expected, and requires PHP.

Its syntax is in general very basic PHP so if you know what that is you know what to expect.

Instead of using <? of PHP you will use {}

which is very similar to a Laravel solution if I’m honest.

The similarities end there as the syntax is more n turn now put in a bit of self contained

as lines seem to be connected by simple {} so every code line needs to be set like that -or the documentation and project lead me to think about that.

Outside of that this is just very much PHP

other deep functionality functions which i plan to cover in a following blog since I’m interested now, deal with customization, inserting, and configuration.

I see a possible technology if a bit niche, and hey maybe Ill help someone trying to understand this tech

sources:

https://www.smarty.net/

Documentation

https://www.smarty.net/docs/en/

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s