Anyone here using template engines instead of pure HTML?
-
sebflo
- Verified Member

- Posts: 138
- Joined: October 9th, 2018, 1:16 pm
Anyone here using template engines instead of pure HTML?
I generally use HTML and SCSS or CSS. However I have worked on a few projects that use Blade or Twig template engines. Gotta say Its very clean and easy to write, but its taken a bit of getting used to with my development workflow.
Anyone use a template engine for their projects? What are your thoughts?
Anyone use a template engine for their projects? What are your thoughts?
- Kev
- Verified Member

- Posts: 534
- Joined: March 3rd, 2018, 11:07 am
- koster
- Verified Member

- Posts: 954
- Joined: June 25th, 2018, 4:42 am
- Contact:
css confuses the hell out of me. I am fighting with my blog css's all the time.
-
sebflo
- Verified Member

- Posts: 138
- Joined: October 9th, 2018, 1:16 pm
Keep me in mind if you ever need help with it.
-
Colmike7
- Banned

- Posts: 1670
- Joined: May 23rd, 2018, 12:21 pm
- Title: (>^-^)b
Same here, just post a thread with any CSS questions. ^
Keep things simple, read up on CSS things when you have down time, inspect element on FF is very useful for debugging and testing, coding things from scratch rather than modifying someone else's code makes things a lot easier in the long run although there's more time involved, etc.
Keep things simple, read up on CSS things when you have down time, inspect element on FF is very useful for debugging and testing, coding things from scratch rather than modifying someone else's code makes things a lot easier in the long run although there's more time involved, etc.
-
calista
- Verified Member

- Posts: 1985
- Joined: February 20th, 2018, 6:15 pm
- Title: Manila Babe
CSS is the only way for me, it is so intuitive once you get a handle on it.
-
greatpornlinks
- Verified Member

- Posts: 1715
- Joined: June 14th, 2018, 6:51 pm
Share some pros and cons pleasesebflo wrote: ↑October 18th, 2018, 3:20 pmI generally use HTML and SCSS or CSS. However I have worked on a few projects that use Blade or Twig template engines. Gotta say Its very clean and easy to write, but its taken a bit of getting used to with my development workflow.
Anyone use a template engine for their projects? What are your thoughts?
Never have your honey where you make your money.
~ HeidiHoe 2023
~ HeidiHoe 2023
- koster
- Verified Member

- Posts: 954
- Joined: June 25th, 2018, 4:42 am
- Contact:
Negative I am a html type of webmaster myself.
-
Colmike7
- Banned

- Posts: 1670
- Joined: May 23rd, 2018, 12:21 pm
- Title: (>^-^)b
-
sebflo
- Verified Member

- Posts: 138
- Joined: October 9th, 2018, 1:16 pm
What do you develop in?
-
sebflo
- Verified Member

- Posts: 138
- Joined: October 9th, 2018, 1:16 pm
Yea neither do I. I stay away from a lot of frameworks because of this.
-
Colmike7
- Banned

- Posts: 1670
- Joined: May 23rd, 2018, 12:21 pm
- Title: (>^-^)b
Me too. I'll end up starting with even a simple framework like Bootstrap, then when I'm done I go in and clean up, then afterwards I'm like "I didn't need a framework for this..." lol
-
sebflo
- Verified Member

- Posts: 138
- Joined: October 9th, 2018, 1:16 pm
Yea I use bootstrap quite a bit, I dont like to use pre-made bootstrap templates though as they are usually pretty messy.
I usually stay away from heavy development frameworks like Laravel or Zend.
Template engines have quite a few benefits. Still though I usually stick with HTML5 and SASS or CSS3.
However Template engines can complement HTML5 and CSS3.
For example take the following.
Twig Username output to div
Code: Select all
<div>
{% for user in users %}
* {{ user.name }}
{% else %}
No users have been found.
{% endfor %}
</div>
Code: Select all
<div>
<?php if($users): ?>
<?php foreach($users as $user): ?>
<?= $user['name']; ?>
<?php endforeach; ?>
<? else: ?>
No users have been found.
<?php endif; ?>
</div>
-
Colmike7
- Banned

- Posts: 1670
- Joined: May 23rd, 2018, 12:21 pm
- Title: (>^-^)b
That's pretty neat, I might look into Twig more. For a while I thought it was more of a macro kind of thing to make PHP seem easier, and why I never really paid attention to it, but it's more like separating the logic with the PHP and front end display code, which can make big projects and changes easier and quicker. Or to give a designer the front end part and not have to worry about getting lost in someone else's PHP.sebflo wrote: ↑October 23rd, 2018, 4:33 pmYea I use bootstrap quite a bit, I dont like to use pre-made bootstrap templates though as they are usually pretty messy.
I usually stay away from heavy development frameworks like Laravel or Zend.
Template engines have quite a few benefits. Still though I usually stick with HTML5 and SASS or CSS3.
However Template engines can complement HTML5 and CSS3.
For example take the following.
Twig Username output to div
Compared to a core php versionCode: Select all
<div> {% for user in users %} * {{ user.name }} {% else %} No users have been found. {% endfor %} </div>
Sure not the only way to get the result but look at how clean the twig version looks compared to the core php version.Code: Select all
<div> <?php if($users): ?> <?php foreach($users as $user): ?> <?= $user['name']; ?> <?php endforeach; ?> <? else: ?> No users have been found. <?php endif; ?> </div>
I do like regular PHP a lot, though, so it might still be hard to persuade me to use something else lol.
I agree with the heavy frameworks, too. Sure, I can read a ton and learn another way to do the same thing with something a little fancier, but why would I want to if I don't need to for the same end result?
-
sebflo
- Verified Member

- Posts: 138
- Joined: October 9th, 2018, 1:16 pm
Yea twig is pretty sweet, definitely not needed but it does help separate php or similar from html.Colmike7 wrote: ↑October 23rd, 2018, 5:36 pmThat's pretty neat, I might look into Twig more. For a while I thought it was more of a macro kind of thing to make PHP seem easier, and why I never really paid attention to it, but it's more like separating the logic with the PHP and front end display code, which can make big projects and changes easier and quicker. Or to give a designer the front end part and not have to worry about getting lost in someone else's PHP.sebflo wrote: ↑October 23rd, 2018, 4:33 pmYea I use bootstrap quite a bit, I dont like to use pre-made bootstrap templates though as they are usually pretty messy.
I usually stay away from heavy development frameworks like Laravel or Zend.
Template engines have quite a few benefits. Still though I usually stick with HTML5 and SASS or CSS3.
However Template engines can complement HTML5 and CSS3.
For example take the following.
Twig Username output to div
Compared to a core php versionCode: Select all
<div> {% for user in users %} * {{ user.name }} {% else %} No users have been found. {% endfor %} </div>
Sure not the only way to get the result but look at how clean the twig version looks compared to the core php version.Code: Select all
<div> <?php if($users): ?> <?php foreach($users as $user): ?> <?= $user['name']; ?> <?php endforeach; ?> <? else: ?> No users have been found. <?php endif; ?> </div>
I do like regular PHP a lot, though, so it might still be hard to persuade me to use something else lol.
I agree with the heavy frameworks, too. Sure, I can read a ton and learn another way to do the same thing with something a little fancier, but why would I want to if I don't need to for the same end result?
Blade is a nice template engine too and is used a lot with laravel.
Yea frameworks like laravel or codeigniter are pretty heavy. I do use them but only when in large teams.
When working with teams I take the following approach.
Front End: Template Engine
Back-end: Laravel or Codeigniter
Database: Stored Procedures
I use this structure because when working on a large team you never know when some one is going to quit or not work out, because Laravel and codeignite have pretty strict rules as far as structures goes, its very easy to have another developer take over a task.
I use Stored procedures to separate database queries from in code queries, so as a database admin I have full control of the queries and can store them. When developers need to access data from a query they can just call a stores procedure.
For example
Code: Select all
$query = $database->prepare("SELECT * FROM table WHERE id = ?");
$query->execute(array($param));
$query = $query->fetchAll(PDO::FETCH_ASSOC);
return $query
Code: Select all
$query = $database->prepare("CALL: get_all(?)"); //Stored procedure is called
$query->execute(array($param));
$query = $query->fetchAll(PDO::FETCH_ASSOC);
return $query
I use this so the developers don't touch the database and just focus on logic.
The front-end guys can then simply access the data returned by the logic and simply output the results with a template engine.
When working alone I tend to do something similar but with less restrictions as it's just me doing front-end, backend, and database work.
Its not the only way to do things, just kinda the way I like to work when it comes to working with team members.