Shift logic to preprocess instead of template.