CodeIgniter Forums

Full Version: CodeIgniter Simple and Secure Twig
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3 4
Hi, I built A Simple and Secure Twig integration for CodeIgniter 3.0.

https://github.com/kenjis/codeigniter-ss-twig

This is really simple implementation. Try it, if you like.
Hi kenjis,
 
Your code not work with CodeIgniter HMVC Modules.

How to fix it?

Thanks
Probably you have to add the paths for view files:
https://github.com/kenjis/codeigniter-ss...ig.php#L35
Thank you! I fixed it!
Hi Kenjis,

I'm interested in including Twig the proper way with CI3.0, but I can't seem to get it to work. I am NOT using composer. How may I get this to work?
(10-01-2015, 06:49 AM)iamthwee Wrote: [ -> ]Hi Kenjis,

I'm interested in including Twig the proper way with CI3.0, but I can't seem to get it to work. I am NOT using composer. How may I get this to work?

Why not use Composer?

Without Composer to install Twig is a lot of pain.

First you read the Twig documentation:
http://twig.sensiolabs.org/doc/installation.html

Install tarball release, and you must register Twig Autoloader with spl_autoload_register(): https://github.com/twigphp/Twig/blob/1.x...loader.php

And install my Twig library: https://github.com/kenjis/codeigniter-ss...s/Twig.php

I think you can use Twig if you install it this way, but I have not installed Twig manually like this.
Thanks, I refuse to use composer. Too much auto downloading of things and stuff in the background which bugs me. (I'm anal about control, stuff I can download unzip and use and see)

In the end I managed to get it sorted by copying the relevant files from

https://github.com/Vheissu/Ci-Twig

I then downloaded the zip from twig's website which has the Autoloader.php file and dropped it in the third party library and it worked like a charm.

Now I just have to put it into my ignitedCMS project and test if it all sings together nicely which I'm sure it will.
Yes but what I was doing was using the twig zip file from here:

https://github.com/fabpot/Twig/tree/master/lib/Twig

Looks like he forked it and removed Autoloader.php, so that was why it was failed. When I downloaded the zip from the twig website it had autoloader.php and worked.

Thanks for all your help. I might not even use templates now, still in a critical decision phase.
Twig autoloader is deprecated: See https://github.com/twigphp/Twig/blob/1.x...er.php#L19

If you use Twig, I recommend you know Twig itself. My Twig.php and Vheissu/Ci-Twig are just wrappers.

And I also recommend you think how to HTML-escape in views. In my opinion, escaping manually (every time you call html_escape() in views when you need) ends up with a lot of XSS vulnerabilities.
Pages: 1 2 3 4