Conditionally show checkbox

58 views
Skip to first unread message

troy

unread,
Oct 17, 2012, 3:21:38 AM10/17/12
to jad...@googlegroups.com
I only want to show a checkbox to people who are logged into my application as administrators. I've tried this:

- var isAdmin = // check role code
- if(isAdmin)
  p
    label(for='myInput')
      input(type='checkbox')

It always renders the checkbox though even if isAdmin is false. What is the correct way to do this?

Thanks,

Troy

Jan Buschtöns

unread,
Oct 17, 2012, 3:24:32 AM10/17/12
to jad...@googlegroups.com
- var isAdmin = // check role code
if(isAdmin)
  p
    label(for='myInput')
      input(type='checkbox')

How 'bout that? :D

Jade natively supports stuff like if and each. When using it as JavaScrito code (which you did by puttign an - infront of it) you have to apply JavaScript Syntax:
- var isAdmin = // check role code
- if(isAdmin) {
  p
    label(for='myInput')
      input(type='checkbox')
- }

Troy Martin

unread,
Oct 17, 2012, 3:46:03 AM10/17/12
to jad...@googlegroups.com
Thanks for your quick response. That worked perfectly!

Best,

Troy
Reply all
Reply to author
Forward
0 new messages