How to write custom fragments for inclusion in macros and dialplans?

Is there a reason this is a new post rather than continuing your previous post?