I didn't mention cache_templates or global_complete, I wouldn't expect it to work in them. I see no obvious reason it wouldn't work in the others, are you sure the code actually works at all ? (looking at what you are trying to replace, I doubt it does, you certainly cannot search for </if> in cached templates).