Support strings > 64kb in templates

Fixes #1755