• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
CodeIgniter Simple and Secure Twig

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

#22
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...ig.php#L25
Do you want to write tests for your apps? Our book, CodeIgniter Testing Guide would help you.
Reply

#23
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?
Reply

#24
(02-21-2016, 07: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.
Do you want to write tests for your apps? Our book, CodeIgniter Testing Guide would help you.
Reply

#25
(02-21-2016, 10:41 PM)kenjis Wrote:
(02-21-2016, 07: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);
Reply

#26
(02-22-2016, 12:26 AM)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.
Do you want to write tests for your apps? Our book, CodeIgniter Testing Guide would help you.
Reply

#27
(02-22-2016, 12:26 AM)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...-templates

You can use `render()` method:
$output = $this->twig->render('welcome', $data);
Do you want to write tests for your apps? Our book, CodeIgniter Testing Guide would help you.
Reply

#28
I sent PR to add user functions.
See https://github.com/kenjis/codeigniter-ss-twig/pull/8
Do you want to write tests for your apps? Our book, CodeIgniter Testing Guide would help you.
Reply

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

Now you can add your functions with configuration.
Do you want to write tests for your apps? Our book, CodeIgniter Testing Guide would help you.
Reply

#30
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!
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


Users browsing this thread:
1 Guest(s)


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.