blockinfile, delete the rest

Hi,

I’d like to edit a file using block in file and delete anything in the file that isn’t in that block, in an idempotent way i,e, not just deleting the file first.

I suspect I should be using a template here but partly want to scratch the itch of whether it’s possible, is there a reasonable way?

Hi,

I’d like to edit a file using block in file and delete anything in the file that isn’t in that block, in an idempotent way i,e, not just deleting the file first.

This would have exactly the same results as using the template module, only harder to do.

I suspect I should be using a template here but partly want to scratch the itch of whether it’s possible, is there a reasonable way?

You probably should. Put differently, why would you not use the template module?