Solidity already supports the low-level CALLCODE opcode (via address.callcode) which allows code from other contracts to be called that still operates on the current contract's storage. It is still very cumbersome to use and not type-safe (similar to its cousin address.call).
The heap example contract
shows how much safer and simpler to use this will be soon. Allowing templated contracts might still take a while, but libraries themselves should be available during the next days. Stay tuned (and post your feedback)!