Extracted the compileDirective function in a separate file