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

Passing locals

kpapadatos opened this issue · comments

Im trying to use this and its not working at all

{
	loader: "pug-html-loader",
	options: {
		pretty:true,
		exports:false,
		data: {foo:"BAR"}
	}
}

In my pug template im trying to access data.foo and webpack compiler is saying error accessing property foo of undefined

commented

+1 on this, doesn't seem to work at all, but

  1. Seems pretty important to the core functionality of what a pug html loader should do.
  2. Doesn't seem like it should be too tricky to do

Just submitted a little patch I've been using.

@stresslimit

  1. Yup
  2. It's all relative, thanks @willyelm et al. for the slick project.

😉 👍

commented

cool thanks @justsml! Of course big thanks @willyelm and hope it merges quickly

it should be working in the latest version which webpack version are you using? also please paste how does your web pack config look like. Thanks!

I just tested it - i was trying to access data.foo in the pug, turns out its just foo :/

So it does work. I could have sworn I saw something somewhere that said to use data.foo to access the locals, which is why I assumed this wasnt working?

Might be worth making an example of how to use the data option in a template, since it seems a few of us have made the same mistake :)

great, I'll close the issue then. I've added it to the readme. Thanks!

commented

Yes just to confirm, I was using with ExtractTextPlugin and it was a bug with that, not pug-html-loader. So thanks! All good.