lodash 中文文档 lodash 中文文档
英文官网 (opens new window)
GitHub (opens new window)
英文官网 (opens new window)
GitHub (opens new window)
  • 简介
  • 数组
  • 集合
  • 函数
  • 语言
  • 数学
  • 数字
  • 对象
  • Seq
  • 字符串
  • 实用函数
  • Properties

karma-lodash-template-preprocessor


Karma preprocessor to compile Lo-Dash templates on the fly.

Installation


  1. ``` sh
  2. npm install karma-lodash-template-preprocessor --save-dev
  3. ```

Configuration


Following code shows the default configuration.

  1. ``` js
  2. // karma.conf.js
  3. module.exports = function( config ) {
  4.   config.set({
  5.     preprocessors: {
  6.       "**/*.template.js": [ "lodash" ]
  7.     },

  8.     lodashPreprocessor: {
  9.       // Template data. You can use function, which returns object
  10.       data: {
  11.         "this will be passed": "to _.template as second argument"
  12.       },
  13.       // Options passed to the _.template function as third argument:
  14.       options: {
  15.         interpolate: /regexp/,
  16.         variable: "info"
  17.         // Full list: http://lodash.com/docs#template
  18.       },

  19.       // Filename transform function ("file.template.js" > "file.js"):
  20.       transformPath: function( path ) {
  21.         return path.replace( /\.template\./i, "." );
  22.       }
  23.     }
  24.   });
  25. };
  26. ```
Last Updated: 2023-05-15 20:35:46