engine.js (648B)
1 'use strict'; 2 3 module.exports = function(name, options) { 4 let engine = options.engines[name] || options.engines[aliase(name)]; 5 if (typeof engine === 'undefined') { 6 throw new Error('gray-matter engine "' + name + '" is not registered'); 7 } 8 if (typeof engine === 'function') { 9 engine = { parse: engine }; 10 } 11 return engine; 12 }; 13 14 function aliase(name) { 15 switch (name.toLowerCase()) { 16 case 'js': 17 case 'javascript': 18 return 'javascript'; 19 case 'coffee': 20 case 'coffeescript': 21 case 'cson': 22 return 'coffee'; 23 case 'yaml': 24 case 'yml': 25 return 'yaml'; 26 default: { 27 return name; 28 } 29 } 30 }