diff --git a/index.js b/index.js
index <HASH>..<HASH> 100644
--- a/index.js
+++ b/index.js
@@ -1,10 +1,17 @@
 var _ = require('lodash');
 var loaderUtils = require('loader-utils');
 
+function getOptions(context) {
+  if (context.options && context.options.ejsLoader) {
+    return context.options.ejsLoader;
+  }
+  return {};
+}
+
 module.exports = function(source) {
   this.cacheable && this.cacheable();
   var query = loaderUtils.parseQuery(this.query);
-  var options = this.options ? this.options.ejsLoader || {} : {};
+  var options = getOptions(this);
 
   ['escape', 'interpolate', 'evaluate'].forEach(function(templateSetting) {
     var setting = query[templateSetting];
refactor: make code more readable and remove ternary