Well, it's not exactly clear what should happen in this situation. Since you can't give orders to build a temple when you are under siege, you might not be able to complete a temple that was ordered to be built in the turn where you are about to become sieged. (In a province where you already have a fort.)
I tested this scenario to see what would happen: the temple will be built inside your fort. So even though construction occurs after all battles, your people were able to finish building the temple inside the fort, with trees they chopped down before your province got invaded

. Tree-chopping happens before combat, it is undocumented turn resolution sequence 2.b Tree Chopping. (joke)
Here's a link to a Battle Simulator map useful for testing this sort of thing, from Gandalf Parker:
http://www.shrapnelcommunity.com/thr...?Number=471188