![]() |
CodeIgniter Simple and Secure Twig - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: External Resources (https://forum.codeigniter.com/forumdisplay.php?fid=7) +--- Forum: Addins (https://forum.codeigniter.com/forumdisplay.php?fid=13) +--- Thread: CodeIgniter Simple and Secure Twig (/showthread.php?tid=61849) |
CodeIgniter Simple and Secure Twig - kenjis - 05-24-2015 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. RE: CodeIgniter Simple and Secure Twig - manhnguyen - 07-01-2015 Hi kenjis, Your code not work with CodeIgniter HMVC Modules. How to fix it? Thanks RE: CodeIgniter Simple and Secure Twig - kenjis - 07-01-2015 Probably you have to add the paths for view files: https://github.com/kenjis/codeigniter-ss-twig/blob/master/libraries/Twig.php#L35 RE: CodeIgniter Simple and Secure Twig - manhnguyen - 07-01-2015 Thank you! I fixed it! RE: CodeIgniter Simple and Secure Twig - ignitedcms - 10-01-2015 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? RE: CodeIgniter Simple and Secure Twig - kenjis - 10-01-2015 (10-01-2015, 06:49 AM)iamthwee Wrote: Hi Kenjis, 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/lib/Twig/Autoloader.php And install my Twig library: https://github.com/kenjis/codeigniter-ss-twig/blob/master/libraries/Twig.php I think you can use Twig if you install it this way, but I have not installed Twig manually like this. RE: CodeIgniter Simple and Secure Twig - ignitedcms - 10-01-2015 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. RE: CodeIgniter Simple and Secure Twig - kenjis - 10-01-2015 It registers Twig autoloader: https://github.com/Vheissu/Ci-Twig/blob/master/libraries/Twig.php#L34-L38 RE: CodeIgniter Simple and Secure Twig - ignitedcms - 10-01-2015 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. RE: CodeIgniter Simple and Secure Twig - kenjis - 10-01-2015 Twig autoloader is deprecated: See https://github.com/twigphp/Twig/blob/1.x/lib/Twig/Autoloader.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. |