{"id":13560285,"url":"https://github.com/edmundask/codeigniter-twiggy","last_synced_at":"2025-04-03T15:31:55.702Z","repository":{"id":2619820,"uuid":"3604252","full_name":"edmundask/codeigniter-twiggy","owner":"edmundask","description":"Twiggy - Twig template engine implementation for CodeIgniter","archived":false,"fork":false,"pushed_at":"2017-10-03T22:06:23.000Z","size":558,"stargazers_count":98,"open_issues_count":15,"forks_count":48,"subscribers_count":22,"default_branch":"master","last_synced_at":"2024-11-04T11:38:52.491Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://edmundask.github.com/codeigniter-twiggy","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/edmundask.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2012-03-02T17:17:31.000Z","updated_at":"2024-01-17T15:48:33.000Z","dependencies_parsed_at":"2022-08-29T12:32:17.523Z","dependency_job_id":null,"html_url":"https://github.com/edmundask/codeigniter-twiggy","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/edmundask%2Fcodeigniter-twiggy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/edmundask%2Fcodeigniter-twiggy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/edmundask%2Fcodeigniter-twiggy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/edmundask%2Fcodeigniter-twiggy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/edmundask","download_url":"https://codeload.github.com/edmundask/codeigniter-twiggy/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247028034,"owners_count":20871639,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-01T13:00:41.014Z","updated_at":"2025-04-03T15:31:50.677Z","avatar_url":"https://github.com/edmundask.png","language":"PHP","readme":"# Twiggy - Twig template engine implementation for CodeIgniter\n\nTwiggy is not just a simple implementation of Twig template engine for CodeIgniter. It supports themes, layouts, templates for regular apps and also for apps that use HMVC (module support). \nIt is supposed to make life easier for developing and maitaining CodeIgniter applications where themes and nicely structured templates are necessary.\n\n## Why Should I Care?\n\nTwig by itself is a very powerful and flexible templating system but with CodeIgniter it is even cooler! With Twiggy you can separately set the theme, layout and template for each page. \nWhat is even more interesting, this does not replace CodeIgniter's default Views, so you can still load views as such: `$this-\u003eload-\u003eview()`.\n\n# Requirements\n\n* PHP 5.2.4+\n* [CodeIgniter](http://codeigniter.com/) 2.x\n\n# How To Use It\n\n## 1. Load library (as a spark)\n\n`$this-\u003eload-\u003espark('twiggy/x.x.x');` where `x.x.x` is the version you want to load (assuming you have it installed).\n\n## 2. Set up dir structure\n\n1. Create a directory structure:\n\n\t```\n    +-{APPPATH}/\n    | +-themes/\n    | | +-default/\n    | | | +-_layouts/\n\t```\n\n\tNOTE: `{APPPATH}` is the folder where all your controllers, models and other neat stuff is placed.\n\tBy default that folder is called `application`.\n\n2. Create a default layout `index.html.twig` and place it in _layouts  folder:\n\n\t```\n\t\u003c!DOCTYPE html\u003e\n\t\u003chtml lang=\"en\"\u003e\n\t\t\u003chead\u003e\n\t\t\t\u003cmeta charset=\"utf-8\"\u003e\n\t\t\t\u003c!--[if lt IE 9]\u003e\n\t\t\t\u003cscript src=\"http://html5shim.googlecode.com/svn/trunk/html5.js\"\u003e\u003c/script\u003e\n\t\t\t\u003c![endif]--\u003e\n\t\t\t\u003ctitle\u003eDefault layout\u003c/title\u003e\n\t\t\u003c/head\u003e\n\t\t\u003cbody\u003e\n\n\t\t\t{% block content %}\n\n\n\n\t\t\t{% endblock %}\n\t\t\t\n\t\t\u003c/body\u003e\n\t\u003c/html\u003e\n\t```\n\n3. Create a default template file `index.html.twig` at the root of `default` theme folder:\n\n\t```\n\t{% extends _layout %}\n\n\t{% block content %}\n\n\t\tDefault template file.\n\n\t{% endblock %}\n\t```\n\n4. You should end up with a structure like this:\n\n\t```\n    +-{APPPATH}/\n    | +-themes/\n    | | +-default/\n    | | | +-_layouts/\n    | | | | +-index.hml.twig\n    | | | +-index.html.twig\n\t```\n\n## 3. Display the template\n\n`$this-\u003etwiggy-\u003edisplay();`\n\n## 4. What's next?\n\nIn the example above we only displayed the default template and layout. Obviously, you can create as many layouts and templates as you want.\nFor example, create a new template file `welcome.html.twig` and load it before sending the output to the browser.\n\n```\n// Whoah, methoding chaining FTW!\n$this-\u003etwiggy-\u003etemplate('welcome')-\u003edisplay();\n```\n\nNotice that you only need to specify the name of the template (without the extension `*.html.twig`).\n\nThere is much more cool stuff that you should check out by visiting the [wiki](https://github.com/edmundask/codeigniter-twiggy/wiki).\n\n# CHANGELOG\n\n### 0.8.5\n\n* Changed `display()` and `render()` methods a little bit to accept a parameter. From now on you can set the template file without the `template()` method. For example: `$this-\u003etwiggy-\u003edisplay('admin/dashboard');` instead of `$this-\u003etwiggy-\u003etemplate('admin/dashboard')-\u003edisplay()`.\n* Added `rendered()` method to check whether a template has already been rendered/displayed using `display()` or `render()`.\n* Fixed a bug where calling `func_get_args()` function as a parameter in another function would cause a fatal error: `Fatal error: func_get_args(): Can’t be used as a function parameter in \u003c...\u003e`.\n\n### 0.8.4\n\n* Fixed a bug where template locations would not be updated correctly after loading a different theme.\n* Changed `autoescape` Twig environment option to `FALSE` in the config file as the default value.\n\n### 0.8.3\n\n* Fixed a bug where global variables would not be available (accessible)\n* Added helper methods for dealing with the title tag.\n* Added helper methods for setting meta data (meta tags).\n\n### 0.8.2\n\n* Fixed a problem with Twig cache. Caching should now work as expected.\n\n### 0.8.1\n\n* Added `unset_data()` method to unset a particular variable, given a key.\n* Fixed a bug where calling render() would throw `Twig_Error_Loader` exception due to missing file extention.\n* Added a private method _load() to load the template and return output object where previously this was done both in render() and display() methods separately.\n* Added `Twig_Error_Loader` exception handling in render() method.\n\n# DONATE\n\n[![test](http://www.pledgie.com/campaigns/16940.png?skin_name=chrome)](http://www.pledgie.com/campaigns/16940)\n\n# COPYRIGHT\n\nCopyright (c) 2012 Edmundas Kondrašovas\n\nPermission is hereby granted, free of charge, to any person obtaining a copy \nof this software and associated documentation files (the \"Software\"), to deal \nin the Software without restriction, including without limitation the rights \nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell \ncopies of the Software, and to permit persons to whom the Software is \nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in \nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR \nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, \nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE \nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER \nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, \nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN \nTHE SOFTWARE.","funding_links":[],"categories":["Templates"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fedmundask%2Fcodeigniter-twiggy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fedmundask%2Fcodeigniter-twiggy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fedmundask%2Fcodeigniter-twiggy/lists"}