I started to extract the logic to a separate project here https://github.com/uklance/tapestry-offline but never got around to testing it.
The main functionality is in this class https://github.com/uklance/tapestry-offline/blob/master/src/main/java/org/lazan/t5/offline/services/internal/OfflineComponentRendererImpl.java Let me know if it's useful, pull requests welcome :)