Remove code duplication in view helper
Merge pull request #10032 from mmun/cleanup-view-helper

Remove code duplication in view helper