Fix JavaScript call in custom templates