-
Notifications
You must be signed in to change notification settings - Fork 13
helper tags
If there are any here that are undocumented they will be soon I promise
please contact me if you are stuck or log an issue I am more than happy to help
- button_to / button_link_to
- cdata
- checkbox_tag
- color_field_tag
- css_tag
- date_tag
- date_time_tag
- doctype_tag
- email_field_tag
- end_tag
- escape_js
- file_field_tag
- form_tag
- form_end_tag
- hidden_field_tag
- img_tag
- image_submit_tag
- input_field_tag
- js_tag
- js_button
- label_for
- link_to
- link_to_if
- link_to_unless
- link_to_unless_current
- mail_to
- number_field_tag
- password_field_tag
- phone_field_tag / telephone_field_tag
- radio_tag
- reset_field_tag
- sanitize_css
- search_field_tag
- select_tag
- single_tag_for
- start_tag_for
- strip_links
- strip_tags
- submit_tag
- tag
- text_area_tag / text_tag
- text_field_tag
- time_tag
- url_field_tag
doctype that are define are:
-
HTML5
-
HTML4s
-
HTML4t
-
HTML4f
-
XHTML1s
-
XHTML1t
-
XHTML1f
-
XHTML1_1
doctype_tag(HTML4s) => <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> doctype_tag() => <!DOCTYPE HTML>
Creates a date tag
date_tag('Installation[date]', new Date(1982, 10,20) )
date_tag('Installation[date]') // just on current time
Creates a time tag
time_tag('Installation[time]', new Date(1982, 10,20) )
time_tag('Installation[time]') // just on current time
Creates a time tag
date_time_tag('Installation[time]', new Date(1982, 10,20) )
date_time_tag('Installation[time]') // just on current time
Creates a css tag
css_tag('/stylesheet/style.css') =>
"<link rel='stylesheet'
href='/stylesheet/style.css'
type='text/css'
charset='utf-8' />"
Creates a checkbox
checkbox_tag('user_check_box', 'user') =>
"<input id='user_check_box' value='user' type='checkbox' name='user_check_box' />"
Creates a radio button
radio_tag('user_radio', 'user') =>
"<input id='user_radio' value='user' type='radio' name='user_radio' />"
Creates a start form tag.
form_tag('/myaction',{multipart: true})
Creates a end form tag.
form_end_tag()
Creates a hidden field.
hidden_field_tag('something[interesting]', 5) =>
"<input id=\'something[interesting]\'
value=\'5\'
type=\'hidden\'
name=\'something[interesting]\'/>"
Creates an image tag.
img_tag('/some.png', 'something') => "<img src='/some.png' alt='something' />"
Creates a javascript script tag
js_tag('/javascript/script.js') =>
"<script type='text/javascript'
src='/javascript/script.js'
charset='utf-8' ></script>"
Creates a label for tag
label_for('user_id') => "<label for=\'user_id\' >User</label>"
label_for('book[user_id]') => "<label for=\'book[user_id]\' >User</label>"
Creates a link to another page.
link_to('hello world', '/something/here') => "<a href='/something/here' >hello world</a>"
Just like link_to if the condition is true. If condition is false it returns name.
Just like link_to if the condition is false. If condition is true it returns name.
Returns a password field.
password_field_tag('something[interesting]', 5) =>
"<input id='something[interesting]'
value='5'
type='password'
name='something[interesting]'/>"
Returns a select tag.
var choices = [ {value: 1, text: 'First Choice' },
{value: 2, text: 'Second Choice'},
{value: 3, text: 'Third Choice'} ]
select_tag('mySelectElement', 2, choices) =>
"<select id='mySelectElement' value='2' name='mySelectElement'>
<option value='1' >First Choice</option>
<option value='2' selected='selected'>Second Choice</option>
<option value='3'>Third Choice</option>
</select>"
Creates a submit tag.
submit_tag('Submit This') => "<input type=\'submit\' value=\'Submit This\' />"
submit_tag() => "<input type=\'submit\' value=\'Submit\' />"
submit_tag({class:'button'}) => "<input class='button' type=\'submit\' value=\'Submit\' />"
submit_tag('holla', '/new/location') =>
"<input onclick='window.location=\"/new/location\";return false;'
value='holla'
type='submit' />"
Both create a text area tag
text_area_tag('task[description]', 'Here is some text.\nA new line.') =>
text_tag('task[description]', 'Here is some text.\nA new line.') =>
"<textarea id='task[description]'
name='task[description]'
cols='50'
rows='4' >Here is some text.\nA new line.</textarea>"
text_field_tag('something[interesting]', 5) =>
"<input id='something[interesting]'
value='5'
type='text'
name='something[interesting]'/>"