fix bug of template replace