Javascript: Save templates