Refactoring chunk logic to split "chunk-for-node" into a separate function that can be called from other templates.