Skip to content

Instantly share code, notes, and snippets.

@Enome
Created May 18, 2012 20:13
Show Gist options
  • Save Enome/2727378 to your computer and use it in GitHub Desktop.
Save Enome/2727378 to your computer and use it in GitHub Desktop.
mixin field(type, name, label)
-var form_model = locals.form_model || {}
if type === 'hidden'
input(name=name, type=type, value=form_model[name])
else
.control-group(class=locals.fieldClass(name, locals.errors))
label.control-label(for='id_' + name) #{label}
.controls
if type == 'textarea'
.input
textarea.span6(id='id_' + name, name=name)= form_model[name]
else
.input
input.span6(id='id_' + name, name=name, type=type, value=form_model[name])
mixin submit(text)
button.btn.btn-large.btn-success #{text}
mixin csrf()
input(type='hidden', name='authenticity_token', value=locals.session._csrf)
mixin errors()
-var errors = locals.errors;
- if (typeof(errors) != 'undefined')
.alert.alert-error
ul
each v, k in errors
li
b= k + ': '
span= v.join(', ')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment