extract this if/else block to a private method returning the correct RenderedTemplate