Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Variable not shared #47

Closed
sayll opened this issue Jul 30, 2016 · 3 comments
Closed

Variable not shared #47

sayll opened this issue Jul 30, 2016 · 3 comments

Comments

@sayll
Copy link

sayll commented Jul 30, 2016

//  var.jade
-var path='test';

// meta.jade
include ./var.jade;

// index.jade
doctype html
html
    head
        include ./meta.jade
    body
        include ./header
// header.jade
p #{path}
@TimothyGu
Copy link
Member

This is because pug-loader, according to Webpack tradition, uses Webpack's require when include is involved. For this reason, the child file will not have access to the parent's variables, like it usually does. To fix this, you'll have to set the variable as a part of the locals object, which is passed through the includes.

//  var.jade
-locals.path='test';

// meta.jade
include ./var.jade;

// index.jade
doctype html
html
    head
        include ./meta.jade
    body
        include ./header
// header.pug
p #{path}

@TimothyGu TimothyGu reopened this Aug 5, 2016
@sayll
Copy link
Author

sayll commented Aug 5, 2016

thanks

@TimothyGu
Copy link
Member

Check out #54. We've decided to make your original code work again.

samogot added a commit to samogot/pug-loader that referenced this issue Jan 5, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants