The home crowd were left stunned when Jamie Duff netted in the 15th minute to give the visitors a shock early lead.
However, Dean Shiels was on hand to restore parity just seven minutes later.
Templeton grabbed his first on the half-hour mark, before Lee McCulloch made it 3-1 on the stroke of half time.
Ally McCoist did not have to wait long after half time for his side to score their fourth, as Templeton bagged his second of the afternoon in the 49th minute.
McCulloch then completed the scoring in the 58th minute.