Welcome Guest, Not a member yet? Register   Sign In
CodeIgniter Simple and Secure Twig
#1

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.
Reply
#2

Hi kenjis,
 
Your code not work with CodeIgniter HMVC Modules.

How to fix it?

Thanks
Reply
#3

Probably you have to add the paths for view files:
https://github.com/kenjis/codeigniter-ss...ig.php#L35
Reply
#4

Thank you! I fixed it!
Reply
#5

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?
Practical guide to IgnitedCMS - Book coming soon, www.ignitedcms.com
Reply
#6

(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.
Reply
#7

(This post was last modified: 10-01-2015, 09:57 AM by ignitedcms.)

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.
Practical guide to IgnitedCMS - Book coming soon, www.ignitedcms.com
Reply
#8

It registers Twig autoloader:
https://github.com/Vheissu/Ci-Twig/blob/...hp#L34-L38
Reply
#9

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.
Practical guide to IgnitedCMS - Book coming soon, www.ignitedcms.com
Reply
#10

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.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB