lodash / babel-plugin-lodash

Modular Lodash builds without the hassle.
Other
1.96k stars 92 forks source link

_.forOwn is not a function in template when use babel-plugin-lodash #165

Closed grantCHG closed 7 years ago

grantCHG commented 7 years ago
import _ from 'lodash';
_.template('<%\_.forOwn...%>')({ 'user': 'mustache' })
jdalton commented 7 years ago

Yep. Inspecting strings isn't such a doable thing. You can pass an imports option to _.template.

_.template('<%_.forOwn...%>', {
  'imports': { 'forOwn': _.forOwn }
})({ 'user': 'mustache' })