mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-01 07:47:49 +00:00
Make getFunctionSource support number values for indent in build.js.
Former-commit-id: 5f977d8058f6773fdffa09f01a59135e9ea3337a
This commit is contained in:
10
build.js
10
build.js
@@ -783,7 +783,7 @@
|
||||
}
|
||||
var filePath = path.join(directory, filename),
|
||||
text = fs.readFileSync(filePath, 'utf8'),
|
||||
precompiled = cleanupCompiled(getFunctionSource(_.template(text, null, options))),
|
||||
precompiled = cleanupCompiled(getFunctionSource(_.template(text, null, options), 2)),
|
||||
prop = filename.replace(/\..*$/, '');
|
||||
|
||||
source.push(" templates['" + prop.replace(/['\n\r\t]/g, '\\$&') + "'] = " + precompiled + ';', '');
|
||||
@@ -1057,13 +1057,15 @@
|
||||
*
|
||||
* @private
|
||||
* @param {Function} func The function to process.
|
||||
* @param {String} indent The function indent.
|
||||
* @param {Number|String} [indent=0] The level to indent.
|
||||
* @returns {String} Returns the formatted source.
|
||||
*/
|
||||
function getFunctionSource(func, indent) {
|
||||
var source = func.source || (func + '');
|
||||
if (indent == null) {
|
||||
indent = ' ';
|
||||
|
||||
indent || (indent = '');
|
||||
if (typeof indent == 'number') {
|
||||
indent = Array(indent + 1).join(' ');
|
||||
}
|
||||
// format leading whitespace
|
||||
return source.replace(/\n(?:.*)/g, function(match, index) {
|
||||
|
||||
Reference in New Issue
Block a user