/* ### Mock.heredoc(fn) * Mock.heredoc(fn) 以直观、安全的方式书写(多行)HTML 模板。 **使用示例**如下所示: var tpl = Mock.heredoc(function() { /*! {{email}}{{age}} *\/ }) **相关阅读** * [Creating multiline strings in JavaScript](http://stackoverflow.com/questions/805107/creating-multiline-strings-in-javascript)、 */ export function heredoc(fn: Function) { // 1. 移除起始的 function(){ /*! // 2. 移除末尾的 */ } // 3. 移除起始和末尾的空格 return fn .toString() .replace(/^[^\/]+\/\*!?/, '') .replace(/\*\/[^\/]+$/, '') .replace(/^[\s\xA0]+/, '') .replace(/[\s\xA0]+$/, ''); // .trim() }