Added TextTemplateEncoder.

Closes #1072.