negibouze / html-webpack-pug-plugin

Pug/Jade extension for the HTML Webpack Plugin
MIT License
29 stars 7 forks source link

adjustHeadElementsIndentation() shouldn't flatten the indentation of nested elements #9

Closed buo closed 7 years ago

buo commented 7 years ago

Here is my code snippet:

// layout.pug
head
    meta(charset="utf-8")
    title
        block title
    link(rel="stylesheet" href="style.css")
    script(src="script.js")
body
    block body

I have title block in head element so that I can set the title in child template as follows:

// index.pug
extends layout

block title
    | Welcome

block body
    h1 Welcome

But adjustHeadElementsIndentation() flattens the indentation of head elements and generates unwanted result:

// generated layout.pug
head
    meta(charset="utf-8")
    title
    block title
    link(rel="stylesheet" href="style.css")
    script(src="script.js")
body
    block body
buo commented 7 years ago

Another examples are inline style and script.

// before
head
    style(type="text/css").
        body {
            font-size: 13px;
        }
    script(type="text/javascript").
        var MY_VAR = 'foobar';
// after
head
    style(type="text/css").
    body {
    font-size: 13px;
    }
    script(type="text/javascript").
    var MY_VAR = 'foobar';
negibouze commented 7 years ago

Thank you for your report.

negibouze commented 7 years ago

I released a new version (v0.2.0).

buo commented 7 years ago

It works very well. Thank you 👍