extract common view code