Bug #1698: Fix bug in Template::trim