Move post code to separate directive