Conversation
1 similar comment
demurgos
left a comment
There was a problem hiding this comment.
Rest parameters are available by default in Node 6 and above so there should be no issue with the versions supported by Hexo.
I added some other comments but overall it's a good change. Thanks.
I'd still would prefer others to check this PR.
| const end = arguments[5]; | ||
| const args = arguments[3].split('=').shift(); | ||
| let content = arguments[4]; | ||
| data.content = data.content.replace(rBacktick, ($0, start, $2, _args, content, end) => { |
There was a problem hiding this comment.
It would be better to use non-capturing groups (?: ) in the regular expressions to avoid unused arguments.
There was a problem hiding this comment.
\2 is used in the RegExp literal and can not be deleted with node v6.
const rBacktick = /(\s*)(`{3,}|~{3,}) *(.*) *\n([\s\S]+?)\s*\2(\n+|$)/g;
lib/plugins/renderer/swig.js
Outdated
| swig.setTag('for', forTag.parse, function(compiler, args, content, parents, options, blockName) { | ||
| const compile = forTag.compile.apply(this, arguments).split('\n'); | ||
| swig.setTag('for', forTag.parse, function(...args) { | ||
| const compile = forTag.compile.apply(this, args).split('\n'); |
There was a problem hiding this comment.
Is the thisArg used in forTag.compile? If no, it could be simplified to forTag.compile(...args).split('\n')
There was a problem hiding this comment.
I do not know if the value of this in the callback of swig.setTag() and the value of this in forTag.compile() do not know whether it works correctly or not.
There was a problem hiding this comment.
https://github.com/node-swig/swig-templates/blob/master/lib/tags/for.js
swig-tamplate@v2.0.2 does not use thisArg.
|
So, I tracked the relevant Node versions and I confirm it's fine. Rest parameters are supported since Node 6. |
* refactor: split function * lodash.toArray to rest param * remove arguments * no use arguments * fix param * forTag.compile() does not use thisArg.
Thank you for creating a pull request to contribute to Hexo code! Before you open the request please review the following guidelines and tips to help it be more easily integrated: