Fixed extension for templates, and added templates support in the library.
Close #1614