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

Alias include folders? #1532

Closed
max-degterev opened this issue May 16, 2014 · 2 comments
Closed

Alias include folders? #1532

max-degterev opened this issue May 16, 2014 · 2 comments

Comments

@max-degterev
Copy link

Hi! I'm having a wee bit of a trouble including files.

We had a restructuring of our apps to abstract common parts like js, css and templates, and sometimes I have to do includes like include ../../../../../core/templates/awesome.jade

Is there a way to somehow alias that so I could just use include core/awesome.jade? Similar to NODE_PATH.

I found this filename option, but it's unclear if it does what I want...

Thanks!

@ForbesLindesay
Copy link
Member

filename should always be set to the name of the file you are compiling. It is used to resolve relative includes/extends/etc.

The basedir option does what you're after. It determines what happens for absolute paths.

e.g.

/hello-world/foo.jade

= 'foo'

/hello-world/bar/baz/foo/bing.jade

include /foo.jade

index.js

var str = jade.renderFile('/hello-world/bar/baz/foo/bing.jade', {basedir: '/hello-world'});

results in

foo

@max-degterev
Copy link
Author

@ForbesLindesay thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants