refactor template inclusion into ast selector