Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/helloandre/ci-twig
Twig Library for CodeIgniter
https://github.com/helloandre/ci-twig
Last synced: about 1 month ago
JSON representation
Twig Library for CodeIgniter
- Host: GitHub
- URL: https://github.com/helloandre/ci-twig
- Owner: helloandre
- License: mit
- Created: 2014-02-12T21:29:25.000Z (almost 11 years ago)
- Default Branch: master
- Last Pushed: 2014-02-12T21:29:50.000Z (almost 11 years ago)
- Last Synced: 2024-10-27T17:30:38.871Z (3 months ago)
- Size: 102 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE-MIT
Awesome Lists containing this project
README
# CI-Twig
A [CodeIgniter](http://codeigniter.com) library that enables the use of [Twig](http://twig.sensiolabs.org/)
## Installation
You must have Twig installed. See [Twig's how-to](http://twig.sensiolabs.org/doc/intro.html#installation) on how to do that.
Clone this repository. Then copy over all files to their respective directories.
## Usage
This library aims to completely replace CodeIgniter's default Output library (as used by `$this->load->view()`).
Simply load the library
$this->load->library('twig');
Then when you wish to output a view call it with$this->twig->view('myview');
The `view` and `render` functions behave the same way as CI's default Output library.## JSON
This library also comes with a few convenience methods (and a default template) to help with the output of JSON.
A shotgun approach:
$this->twig->json(array('message' => 'json output here'));
Some helper methods:// failing
$this->twig->fail("There was an error");
// succeeding
$this->twig->success();
## ErrorsA convinience method to output a standard error template is provided. See config file to change the default template.
$this->twig->error("There was an error");
## ConfigSee the included config file to change any defaults.