render template according to reqested format

Hi!

I found that template was rendered with json even if I asked for xml.
I fixed it. Please, check.