-
-
Save spac3unit/48c22e1d27aedd26372ab96d04f2d214 to your computer and use it in GitHub Desktop.
pug mixin for easy form field creation
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 inputText(id, label, val) | |
| div.row | |
| label(for= id)= label | |
| input(type="text", name= id, id= id, value= val,autocomplete="off") | |
| mixin inputPassword(id, label, val) | |
| div.row | |
| label(for= id)= label | |
| input(type="password", name= id, id= id, value= val,autocomplete="off") | |
| mixin inputTextfield(id, label, val) | |
| div.row | |
| label(for= id)= label | |
| textarea(rows="5", name= id, id= id, value= val,autocomplete="false") | |
| mixin inputToggle(id, label, checked) | |
| div.row | |
| label(for= id) | |
| input(type="checkbox", name= id, id= id, checked= checked, autocomplete="off") | |
| span= label | |
| mixin inputSelect(id, label, selected, vals) | |
| div.row | |
| label(for= label)= label | |
| select(id= id, name= id) | |
| each val in vals | |
| - var isSelected = (selected==val[1]) ? true : false | |
| option(value= val[0], selected= isSelected)= val[1] | |
| mixin inputToggleCollection(id, label, vals, checked) | |
| - var active = [] | |
| - if (checked!=undefined) { | |
| - active = checked.split(",") | |
| - } | |
| fieldset | |
| legend= label | |
| each val in vals | |
| - var isSelected = (active.indexOf(val)>-1) ? true : false | |
| +inputToggle(val.replace(/\s/g,''), val, isSelected) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment