pugjs / pug-loader

Pug loader module for Webpack
MIT License
425 stars 119 forks source link

Including other templates returns broken JS instead of HTML in 2.1.0 #44

Closed vdh closed 8 years ago

vdh commented 8 years ago

I've been attempting to upgrade from jade-loader to pug-loader, but trying to include a nested template generates broken tags that look to be created from the raw JS template function, instead of the expected HTML output.

// index.pug
doctype html
html
  head
  body
    #loading
      include ./components/Spinner/fouc-spinner.pug
    #root

// ./components/Spinner/fouc-spinner.pug
.spinner-grid-fouc
  .spinner-cube.spinner-cube1
  .spinner-cube.spinner-cube2
  .spinner-cube.spinner-cube3
  .spinner-cube.spinner-cube4
  .spinner-cube.spinner-cube5
  .spinner-cube.spinner-cube6
  .spinner-cube.spinner-cube7
  .spinner-cube.spinner-cube8
  .spinner-cube.spinner-cube9

becomes:

<!DOCTYPE html>
<html>
  <head></head>
  <body>
    <div id="loading"><var>pug = require("!./../../../node_modules/pug-runtime/index.js");</var><function>template(locals) {var pug_html = "", pug_mixins = {}, pug_interp;var pug_indent = [];</function><pug_html>= pug_html + "\n\u003Cdiv class=\"spinner-grid-fouc\"\u003E\n  \u003Cdiv class=\"spinner-cube spinner-cube1\"\u003E\u003C\u002Fdiv\u003E\n  \u003Cdiv class=\"spinner-cube spinner-cube2\"\u003E\u003C\u002Fdiv\u003E\n  \u003Cdiv class=\"spinner-cube spinner-cube3\"\u003E\u003C\u002Fdiv\u003E\n  \u003Cdiv class=\"spinner-cube spinner-cube4\"\u003E\u003C\u002Fdiv\u003E\n  \u003Cdiv class=\"spinner-cube spinner-cube5\"\u003E\u003C\u002Fdiv\u003E\n  \u003Cdiv class=\"spinner-cube spinner-cube6\"\u003E\u003C\u002Fdiv\u003E\n  \u003Cdiv class=\"spinner-cube spinner-cube7\"\u003E\u003C\u002Fdiv\u003E\n  \u003Cdiv class=\"spinner-cube spinner-cube8\"\u003E\u003C\u002Fdiv\u003E\n  \u003Cdiv class=\"spinner-cube spinner-cube9\"\u003E\u003C\u002Fdiv\u003E\n\u003C\u002Fdiv\u003E";;return pug_html;};</pug_html><module class="exports">= template;</module>
    </div>
    <div id="root"></div>
  </body>
</html>
TimothyGu commented 8 years ago

This should be fixed in 2.2.0. Thanks for testing!

cdll commented 4 years ago

got

<var>pug = require("!../node_modules/pug-runtime/index.js");</var>

now with pug-loader@2.4.0