fixed template replace global issue