Skip to content

Commit 0cd3415

Browse files
committed
Update README.md
1 parent 60e8fa0 commit 0cd3415

File tree

1 file changed

+27
-3
lines changed

1 file changed

+27
-3
lines changed

README.md

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff 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+
7486
Render Twig template and output to browser:
7587

7688
~~~php
@@ -89,6 +101,18 @@ $output = $this->twig->render('welcome', $data);
89101

90102
Above 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

0 commit comments

Comments
 (0)