fix javascript template problem; closes #336