Fix logic error in js template