Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/njh/twig-html-helpers
Rails style view helpers for HTML tags in PHP Twig
https://github.com/njh/twig-html-helpers
php php-twig
Last synced: 21 days ago
JSON representation
Rails style view helpers for HTML tags in PHP Twig
- Host: GitHub
- URL: https://github.com/njh/twig-html-helpers
- Owner: njh
- License: other
- Created: 2013-01-24T09:25:18.000Z (over 11 years ago)
- Default Branch: main
- Last Pushed: 2021-07-30T11:13:35.000Z (almost 3 years ago)
- Last Synced: 2024-05-14T01:03:21.229Z (about 1 month ago)
- Topics: php, php-twig
- Language: PHP
- Homepage:
- Size: 22.5 KB
- Stars: 13
- Watchers: 3
- Forks: 8
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Lists
- awesome-twig - HTML Helpers - Rails style view helpers for HTML tags in PHP Twig (Twig / Extensions)
- awesome-twig - HTML Helpers - Rails style view helpers for HTML tags in PHP Twig (Twig / Extensions)
README
Twig HTML Helpers Extension
===========================[![Build Status](https://travis-ci.org/njh/twig-html-helpers.svg?branch=master)](https://travis-ci.org/njh/twig-html-helpers)
This [PHP Twig] extension adds the following Rails style HTML helpers:
* ```check_box_tag($name, $value = '1', $default = false, $options = array())```
* ```content_tag($name, $content='', $options=array())```
* ```hidden_field_tag($name, $default = null, $options = array())```
* ```html_tag($name, $options=array())```
* ```image_tag($src, $options=array())```
* ```input_tag($type, $name, $value=null, $options=array())```
* ```label_tag($name, $text = null, $options = array())```
* ```labelled_text_field_tag($name, $default = null, $options = array())```
* ```link_tag($title, $url=null, $options=array())```
* ```password_field_tag($name = 'password', $default = null, $options = array())```
* ```radio_button_tag($name, $value, $default = false, $options = array())```
* ```reset_tag($value = 'Reset', $options = array())```
* ```select_tag($name, $options, $default = null, $html_options = array())```
* ```submit_tag($value = 'Submit', $options = array())```
* ```text_area_tag($name, $default = null, $options = array())```
* ```text_field_tag($name, $default = null, $options = array())```To use them, first add the extension to your ```composer.json```:
"require": {
"njh/twig-html-helpers": "dev-master"
},Then load it into your environment:
$twig = new Twig_Environment();
$twig->addExtension(new Twig_Extension_HTMLHelpers());You can then use them in your Twig templates:
{{ link_tag('http://www.example.com/') }}
[PHP Twig]: http://twig.sensiolabs.org