File tree Expand file tree Collapse file tree 1 file changed +27
-3
lines changed Expand file tree Collapse file tree 1 file changed +27
-3
lines changed Original file line number Diff line number Diff line change @@ -65,12 +65,24 @@ Remove comment marks below and fix the path for `Autoloader.php`:
6565
6666## Usage
6767
68- Load Twig library:
68+ ### Loading Twig Library
6969
7070~~~ php
71- $this->load->library('Twig ');
71+ $this->load->library('twig ');
7272~~~
7373
74+ You can override the default configration:
75+
76+ ~~~ php
77+ $config = [
78+ 'paths' => ['/path/to/twig/templates', VIEWPATH],
79+ 'cache' => '/path/to/twig/cache',
80+ ];
81+ $this->load->library('twig', $config);
82+ ~~~
83+
84+ ### Rendering Templates
85+
7486Render Twig template and output to browser:
7587
7688~~~ php
@@ -89,6 +101,18 @@ $output = $this->twig->render('welcome', $data);
89101
90102Above code renders ` views/welcome.twig ` .
91103
104+ ### Adding a Global Variable
105+
106+ ~~~ php
107+ $this->twig->addGlobal('sitename', 'My Awesome Site');
108+ ~~~
109+
110+ ### Getting Twig_Environment Instance
111+
112+ ~~~ php
113+ $twig = $this->twig->getTwig();
114+ ~~~
115+
92116### Supported CodeIgniter Helpers
93117
94118* ` base_url `
@@ -114,7 +138,7 @@ $ composer install
114138$ phpunit
115139~~~
116140
117- ## Other Implementations for CodeIgniter 3.0
141+ ## Other Twig Implementations for CodeIgniter 3.0
118142
119143* https://gitlab.com/david-sosa-valdes/ci-attire
120144
You can’t perform that action at this time.
0 commit comments