【问题标题】:Grunt: Get current file name in task configGrunt:在任务配置中获取当前文件名
【发布时间】:2016-01-06 12:50:33
【问题描述】:

在配置我的任务时,我想使用当前文件名,该任务在任务options 对象中作为模板变量工作。例如在options['wrap-start'] 这里:

swig_compile: {
  temptarget: {
    options: {
      'wrap-start': 'var <%= CURRENT.FILE.NAME %> = function {', //I want the current file name as function name here 
      'wrap-end': '};'
    },
    files: {
      '<%= config.app %>/scripts/tempcompiled.js': ['<%= config.app %>/templates/*.swig']
    }
  }
}

【问题讨论】:

    标签: gruntjs


    【解决方案1】:

    根据grunt-swig-compile sources,没有这个功能。 options['wrap-start'] 按原样连接到结果。

    您可以分叉/复制 grunt-swig-compile 源代码,只需在 options['wrap-start'] 中用 path.basename(filepath) 替换您的模式(例如 &lt;%= file_name %&gt;)。

    【讨论】:

      猜你喜欢
      • 2018-03-14
      • 2011-08-18
      • 1970-01-01
      • 2023-03-21
      • 1970-01-01
      • 1970-01-01
      • 2010-10-26
      • 2014-03-15
      • 1970-01-01
      相关资源
      最近更新 更多