willyelm / pug-html-loader

Pug HTML loader for webpack

Home Page:https://github.com/willyelm/pug-html-loader

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Does the pug-html-loader support to pass functions?

dxcqcv opened this issue · comments

commented

I wanna pass a function to pug, and using pug-html-loader to load pug,

in webpack.config.js

  {
    test:/\.pug$/,
    exclude: ['/node_modules/'],
    loader: 'pug-html-loader',
    query: {
      data: {bb:function(str){return str + '444';},aa:'666'},
      pretty: true
    }
  },

in pug file

p!= data.aa
p!= data.bb(data.aa)

use data.aa is OK, but get error when use data.bb

Html Webpack Plugin:
  Error: Child compilation failed:
  Module build failed: TypeError: data.bb is not a function




  - TypeError: data.bb is not a function

  - compiler.js:76 
    [resume]/[html-webpack-plugin]/lib/compiler.js:76:16

  - Compiler.js:214 Compiler.
    [lib]/[webpack]/lib/Compiler.js:214:10

  - Compiler.js:403 
    [lib]/[webpack]/lib/Compiler.js:403:12

  - Tapable.js:67 Compiler.next
    [lib]/[webpack]/[tapable]/lib/Tapable.js:67:11

  - CachePlugin.js:40 Compiler.
    [lib]/[webpack]/lib/CachePlugin.js:40:4

  - Tapable.js:71 Compiler.applyPluginsAsync
    [lib]/[webpack]/[tapable]/lib/Tapable.js:71:13

  - Compiler.js:400 Compiler.
    [lib]/[webpack]/lib/Compiler.js:400:9

  - Compilation.js:577 Compilation.
    [lib]/[webpack]/lib/Compilation.js:577:13

  - Tapable.js:60 Compilation.applyPluginsAsync
    [lib]/[webpack]/[tapable]/lib/Tapable.js:60:69

  - Compilation.js:572 Compilation.
    [lib]/[webpack]/lib/Compilation.js:572:10

  - Tapable.js:60 Compilation.applyPluginsAsync
    [lib]/[webpack]/[tapable]/lib/Tapable.js:60:69

  - Compilation.js:567 Compilation.
    [lib]/[webpack]/lib/Compilation.js:567:9

  - Tapable.js:60 Compilation.applyPluginsAsync
    [lib]/[webpack]/[tapable]/lib/Tapable.js:60:69

  - Compilation.js:563 Compilation.
    [lib]/[webpack]/lib/Compilation.js:563:8

  - Tapable.js:60 Compilation.applyPluginsAsync
    [lib]/[webpack]/[tapable]/lib/Tapable.js:60:69

  - Compilation.js:525 Compilation.seal
    [lib]/[webpack]/lib/Compilation.js:525:7

and I already submit an issue to Html Webpack Plugin, link is jantimon/html-webpack-plugin#397

so I wanna know Does the pug-html-loader support to pass functions in query method ?

this package was originally created to avoid using multiple dependencies in the package and get the template as string, if you are looking html-loader support I think best option would be to use the pug-loader

commented

@willyelm but now ever cannot pass any data using pug-html, like this link why?