Created
October 13, 2014 08:51
-
-
Save wlkns/6ae5d09230b7aea04f0f to your computer and use it in GitHub Desktop.
mixin.jade
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| mixin csrf | |
| div | |
| input(type='hidden', name='_csrf', value=csrfToken) | |
| block | |
| mixin formErrors(form) | |
| errors = form.nonFieldErrors().errors | |
| for error in errors | |
| .alert.alert-error= error | |
| mixin field(form, name) | |
| field = form.boundField(name) | |
| errors = field.errors().errors | |
| errorClass = errors.length ? 'error' : '' | |
| .control-group(class=errorClass) | |
| != field.labelTag() | |
| .controls | |
| != field.asWidget({attrs: attributes}) | |
| block | |
| for error in errors | |
| span.help-inline= error | |
| mixin widget(form, name) | |
| field = form.boundField(name) | |
| errors = field.errors().errors | |
| if (errors.length) | |
| - attributes['class'] += ' error' | |
| - attributes['rel'] = 'popover' | |
| - attributes['data-content'] = errors.join('; ') | |
| != field.asWidget({attrs: attributes}) | |
| mixin inlinePersonForm(form) | |
| tr | |
| td: +widget(form, 'firstName')(class='input-medium') | |
| td: +widget(form, 'lastName')(class='input-medium') | |
| td: +widget(form, 'jobTitle')(class='input-medium') | |
| td: +widget(form, 'email')(class='input-medium') | |
| td: +widget(form, 'mobilePhone')(class='input-medium') | |
| td: +widget(form, 'directPhone')(class='input-medium') | |
| mixin phoneNumberForm(form) | |
| .row | |
| .span5: +widget(form, 'number')(class='span5') | |
| .span2: +widget(form, 'type')(class='span2') | |
| mixin emailAddressForm(form) | |
| .row | |
| .span5: +widget(form, 'email')(class='span5') | |
| .span2: +widget(form, 'type')(class='span2') | |
| mixin addressForm(form) | |
| .controls.controls-row | |
| +widget(form, 'address')(class='span5') | |
| +widget(form, 'type')(class='span2') | |
| .controls.controls-row | |
| +widget(form, 'city')(class='span3') | |
| +widget(form, 'county')(class='span2') | |
| +widget(form, 'postCode')(class='span2') | |
| .controls | |
| +widget(form, 'country')(class='span5') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment