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`:
65
65
66
66
## Usage
67
67
68
- Load Twig library:
68
+ ### Loading Twig Library
69
69
70
70
~~~ php
71
- $this->load->library('Twig ');
71
+ $this->load->library('twig ');
72
72
~~~
73
73
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
+
74
86
Render Twig template and output to browser:
75
87
76
88
~~~ php
@@ -89,6 +101,18 @@ $output = $this->twig->render('welcome', $data);
89
101
90
102
Above code renders ` views/welcome.twig ` .
91
103
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
+
92
116
### Supported CodeIgniter Helpers
93
117
94
118
* ` base_url `
@@ -114,7 +138,7 @@ $ composer install
114
138
$ phpunit
115
139
~~~
116
140
117
- ## Other Implementations for CodeIgniter 3.0
141
+ ## Other Twig Implementations for CodeIgniter 3.0
118
142
119
143
* https://gitlab.com/david-sosa-valdes/ci-attire
120
144
You can’t perform that action at this time.
0 commit comments