need to trim after replacing template, it is not possible with callback