Welcome Guest, Not a member yet? Register   Sign In
Twig help or hindrance
#1

What do you guys think of twig/ template libraries?

Are they a help or hindrance to you workflow?

The reason I ask is because I'm working on a CMS and getting to a point where I might need to use PHP and some of codeigniter's useful functions. I know you can load CI functions into twig but you might want to do more.

Is a cleaner syntax worth the hassle?

What do you think?


<?= $variable ?> is so much worse than {{variable}}
Practical guide to IgnitedCMS - Book coming soon, www.ignitedcms.com
Reply
#2

(02-07-2017, 12:36 AM)iamthwee Wrote: ... and getting to a point where I might need to use PHP ...

You're kidding, right?
Reply
#3

(02-07-2017, 12:36 AM)iamthwee Wrote: What do you think?

<?= $variable ?>  is so much worse than {{variable}}

You should do whatever you feel most comfortable with, unless somebody is paying you to do it the other way. I've always used plain PHP:

PHP Code:
<?php echo $variable?>
Reply
#4

(02-07-2017, 12:57 AM)skunkbad Wrote:
(02-07-2017, 12:36 AM)iamthwee Wrote: ... and getting to a point where I might need to use PHP ...

You're kidding, right?

LOL no I am not kidding. The CMS is actually meant to go public so I'm just thinking about workflows that are or are not restrictive.

I actually really liked working with twig syntax but the overall restriction 'you can't use any php' unless specifically piping it to the template was a bit overwhelming.

I also feels it takes away some of the power and familiarity of CI. The CMS is meant to be a 'developers' cms so I'm in two minds as to what to do.

That's why I'm asking the question.
Practical guide to IgnitedCMS - Book coming soon, www.ignitedcms.com
Reply
#5

A demonstration of what I'm doing is show in video below.

It is essentially an expression engine clone... where you can add arbitrary fields and customise any website page. As you can see in the demo it dumps twig syntaxed code into the view files. But like I was saying, the end user might want to do a bit of jazz with CI inbuilt functions or even vanilla PHP? What do you think?

http://recordit.co/ErScplTq0r
Practical guide to IgnitedCMS - Book coming soon, www.ignitedcms.com
Reply
#6

{{ variable }} is what I think. I've abandoned PHP views almost totally.
Reply
#7

(This post was last modified: 02-07-2017, 10:16 AM by ignitedcms.)

(02-07-2017, 09:04 AM)ivantcholakov Wrote: {{ variable }} is what I think. I've abandoned PHP views almost totally.

Yeah that's what I think, the trouble is it makes it really inflexible especially if you want to write your own custom views and submit to the database. (I want the developer's to have full access to all the CI functions without having to learn another syntax.

Twig is purely a front end kinda thing. I was considering using codeigniter's template class as at least to you use it side by side with PHP but the thing is so BASIC it is kind of useless.

I'm leaning towards just using php short tags ugh!
Practical guide to IgnitedCMS - Book coming soon, www.ignitedcms.com
Reply
#8

(02-07-2017, 01:12 AM)iamthwee Wrote:
(02-07-2017, 12:57 AM)skunkbad Wrote:
(02-07-2017, 12:36 AM)iamthwee Wrote: ... and getting to a point where I might need to use PHP ...

You're kidding, right?

... I'm just thinking about workflows that are or are not restrictive.


If that's the case, then disallowing PHP is not the way to go. You'll just inconvenience devs that want it. I never use these Twig, handlebar type template engines. I would if I had to, but given the choice I would never (unless I needed brain dead "designers" to edit them). Even then, they're likely to screw things up, so what's the difference?
Reply
#9

(02-07-2017, 11:10 AM)skunkbad Wrote:
(02-07-2017, 01:12 AM)iamthwee Wrote:
(02-07-2017, 12:57 AM)skunkbad Wrote:
(02-07-2017, 12:36 AM)iamthwee Wrote: ... and getting to a point where I might need to use PHP ...

You're kidding, right?

... I'm just thinking about workflows that are or are not restrictive.


If that's the case, then disallowing PHP is not the way to go. You'll just inconvenience devs that want it. I never use these Twig, handlebar type template engines. I would if I had to, but given the choice I would never (unless I needed brain dead "designers" to edit them). Even then, they're likely to screw things up, so what's the difference?

Yeah that's what I've plumped for in the end. I think the final straw was when I realised dev might need to use their own helpers, and that opens another cans of worms, because you have to create a twig function for each helper. Thanks for the advice.
Practical guide to IgnitedCMS - Book coming soon, www.ignitedcms.com
Reply
#10

@iamthwee

"Yeah that's what I think, the trouble is it makes it really inflexible especially if you want to write your own custom views and submit to the database."

This is not true. Maybe you don't know something or maybe your views are horrible. Anyway.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB