CodeIgniter Forums
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)

Pages: 1 2 3 4


RE: CodeIgniter Simple and Secure Twig - salih24by7 - 02-11-2016

Hi, awesome work, Is there a way to use CI helpers, like form_label, form_input also, I can see form_open,form_close are already in your list.


RE: CodeIgniter Simple and Secure Twig - kenjis - 02-12-2016

If you want to use CI helpers which are not supported, you can post issuse on GitHub.

Probably you can use Form helpers if you add the helper names in the following line:
https://github.com/kenjis/codeigniter-ss-twig/blob/master/libraries/Twig.php#L25


RE: CodeIgniter Simple and Secure Twig - thocutt1020 - 02-21-2016

I think this is awesome library Kenji!

Is there any way in Codeigniter 3.x to render a twig template from within a twig?

For instance if I had inside my twig something like... 


{{ render('season_controller/champions', {'season_id': season.season_id}) }}

It would call my controller and display the output inside the twig. 
If I could do this it would be awesomely handy.
Is this possible?


RE: CodeIgniter Simple and Secure Twig - kenjis - 02-21-2016

(02-21-2016, 06:15 PM)thocutt1020 Wrote: I think this is awesome library Kenji!

Is there any way in Codeigniter 3.x to render a twig template from within a twig?

For instance if I had inside my twig something like... 

{{ render('season_controller/champions', {'season_id': season.season_id}) }}

It would call my controller and display the output inside the twig. 
If I could do this it would be awesomely handy.
Is this possible?

That is calling another controller (from a contorller). CodeIgniter does not support it.
It is limitation (and design) of CodeIgniter.

To make it possible, first, you have to hack CodeIgniter. And I don't
recommend it unless you are an expert of CodeIgniter.


RE: CodeIgniter Simple and Secure Twig - thocutt1020 - 02-21-2016

(02-21-2016, 09:41 PM)kenjis Wrote:
(02-21-2016, 06:15 PM)thocutt1020 Wrote: I think this is awesome library Kenji!

Is there any way in Codeigniter 3.x to render a twig template from within a twig?

For instance if I had inside my twig something like... 

{{ render('season_controller/champions', {'season_id': season.season_id}) }}

It would call my controller and display the output inside the twig. 
If I could do this it would be awesomely handy.
Is this possible?

That is calling another controller (from a contorller). CodeIgniter does not support it.
It is limitation (and design) of CodeIgniter.

To make it possible, first, you have to hack CodeIgniter. And I don't
recommend it unless you are an expert of CodeIgniter.

Thanks for your response!
I see what you are saying...
maybe I can get the functionality I want by creating helper functions and then calling them from within the twig. I will try that.

One other question I was wondering about.
With views, you used to be able to store the output in a variable i.e..
 $string = $this->load->view('myfile', '', true);

Can you achieve same result with twig?
 $string = $this->twig->display('myfile.html', '', true);


RE: CodeIgniter Simple and Secure Twig - kenjis - 02-22-2016

(02-21-2016, 11:26 PM)thocutt1020 Wrote: Thanks for your response!
I see what you are saying...
maybe I can get the functionality I want by creating helper functions and then calling them from within the twig. I will try that.

I know a few solutions. One is HMVC.
Another is widgets: https://github.com/kenjis/codeigniter-widgets

If you really need to call another controller, I don't recommend to use HMVC.
Because it brings complexity to CodeIgniter. But HMVC is very popular library for CodeIgniter.


RE: CodeIgniter Simple and Secure Twig - kenjis - 02-22-2016

(02-21-2016, 11:26 PM)thocutt1020 Wrote: One other question I was wondering about.
With views, you used to be able to store the output in a variable i.e..
 $string = $this->load->view('myfile', '', true);

Can you achieve same result with twig?
 $string = $this->twig->display('myfile.html', '', true);

See https://github.com/kenjis/codeigniter-ss-twig#rendering-templates

You can use `render()` method:
$output = $this->twig->render('welcome', $data);


RE: CodeIgniter Simple and Secure Twig - kenjis - 03-05-2016

I sent PR to add user functions.
See https://github.com/kenjis/codeigniter-ss-twig/pull/8


RE: CodeIgniter Simple and Secure Twig - kenjis - 03-08-2016

I've just released v0.2.0: https://github.com/kenjis/codeigniter-ss-twig/releases

Now you can add your functions with configuration.


RE: CodeIgniter Simple and Secure Twig - mstdmstd - 03-27-2016

Hello,
In doc it is written :
You can override the default configuration:


PHP Code:
$config = [
   'paths' => ['/path/to/twig/templates'VIEWPATH],
   'cache' => '/path/to/twig/cache',
];
$this->load->library('twig'$config); 


That is clear, but I load twig in autoload file, as :

PHP Code:
$autoload['libraries'] = array('ion_auth''twig' ); 


How to overwrite config in this case?

  Thanks!