generate source according to source template