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

path must be a string #28

Open
alexfoxy opened this issue Oct 30, 2012 · 9 comments
Open

path must be a string #28

alexfoxy opened this issue Oct 30, 2012 · 9 comments

Comments

@alexfoxy
Copy link

Hey, I'm trying to use this in Jade:

- partial('partials/facebookSDK')

But it just gives me "path must be a string"

What am I doing wrong?

@slaskis
Copy link
Member

slaskis commented Oct 31, 2012

Could you give me some more details? A stack trace, or even better, example code that can reproduce the error.

@alexfoxy
Copy link
Author

Here's the trace:

path must be a string
    at Object.fs.openSync (fs.js:338:18)
    at Object.fs.readFileSync (fs.js:182:15)
    at ServerResponse.partial (/Users/alexfox/Dropbox/create2.amplify.io/node_modules/express-partials/index.js:274:19)
    at eval (eval at <anonymous> (/Users/alexfox/Dropbox/create2.amplify.io/node_modules/jade/lib/jade.js:176:8))
    at exports.compile (/Users/alexfox/Dropbox/create2.amplify.io/node_modules/jade/lib/jade.js:181:12)
    at Object.exports.render (/Users/alexfox/Dropbox/create2.amplify.io/node_modules/jade/lib/jade.js:216:14)
    at View.exports.renderFile [as engine] (/Users/alexfox/Dropbox/create2.amplify.io/node_modules/jade/lib/jade.js:243:13)
    at View.render (/Users/alexfox/Dropbox/create2.amplify.io/node_modules/express/lib/view.js:75:8)
    at Function.app.render (/Users/alexfox/Dropbox/create2.amplify.io/node_modules/express/lib/application.js:505:10)
    at ServerResponse.res.render [as partial] (/Users/alexfox/Dropbox/create2.amplify.io/node_modules/express/lib/response.js:717:7)

The code in the view is:

- partial('partials/facebookSDK')

And the partial is:

div.
     <div id="fb-root"></div>
     <script>(function(d, s, id) {
     var js, fjs = d.getElementsByTagName(s)[0];
     if (d.getElementById(id)) return;
     js = d.createElement(s); js.id = id;
     js.src = "//connect.facebook.net/en_GB/all.js#xfbml=1&appId=XXXXXXXXXXXXX";
     fjs.parentNode.insertBefore(js, fjs);
     }(document, 'script', 'facebook-jssdk'));</script>

Thanks for the help!

@alexfoxy
Copy link
Author

alexfoxy commented Nov 5, 2012

Any news on this? Is it because the path the partial is wrong?

@tommy351
Copy link

I have same problem:

TypeError: /Users/SkyArrow/Dropbox/hexo/node_modules/hexo-webui/views/layout.html:1
 >> 1| <%- partial('_partial/head') %>
    2| 
    3| <body>
    4|   <%- partial('_partial/header') %>

path must be a string
    at Object.fs.openSync (fs.js:338:18)
    at Object.fs.readFileSync (fs.js:182:15)
    at ServerResponse.partial (/Users/SkyArrow/Dropbox/hexo/node_modules/hexo-webui/node_modules/express-partials/index.js:274:19)
    at eval (eval at <anonymous> (/Users/SkyArrow/Dropbox/hexo/node_modules/hexo-webui/node_modules/ejs/lib/ejs.js:234:12))
    at exports.compile (/Users/SkyArrow/Dropbox/hexo/node_modules/hexo-webui/node_modules/ejs/lib/ejs.js:239:15)
    at Object.exports.render (/Users/SkyArrow/Dropbox/hexo/node_modules/hexo-webui/node_modules/ejs/lib/ejs.js:277:13)
    at View.exports.renderFile [as engine] (/Users/SkyArrow/Dropbox/hexo/node_modules/hexo-webui/node_modules/ejs/lib/ejs.js:303:22)
    at View.render (/Users/SkyArrow/Dropbox/hexo/node_modules/hexo-webui/node_modules/express/lib/view.js:75:8)
    at Function.app.render (/Users/SkyArrow/Dropbox/hexo/node_modules/hexo-webui/node_modules/express/lib/application.js:500:10)
    at ServerResponse.res.render [as partial] (/Users/SkyArrow/Dropbox/hexo/node_modules/hexo-webui/node_modules/express/lib/response.js:716:7)

Layout:

<%- partial('_partial/head') %>

<body>
  <%- partial('_partial/header') %>
  <div id="content">
    <%- body %>
    <%- partial('_partial/footer') %>
  </div>
</body>
</html>

@jimpo
Copy link
Contributor

jimpo commented Nov 25, 2012

Yes, you can get this error if your path is wrong. Please describe your view directory structure.

@sanpago
Copy link

sanpago commented Nov 27, 2012

The function "partial" does not work in this case:

  <%- partial('aaa/bbb') %>

Inside the "partial" function, the variable "name" will be "bbb". This is the result of calling "resolveObjectName(view)".

Then, none of the calls to resolve provide the proper view file path. The "aaa" subdirectory path is lost.

It is necessary to add new resolve checks.

@alex86gbk
Copy link

#19

@itsthatguy
Copy link

I am having the same issue with haml-coffee

@sanpago
Copy link

sanpago commented Feb 14, 2013

It was solved at:

#19

El 14/02/2013, a las 20:19, Kevin Altman [email protected] escribió:

I am having the same issue with haml-coffee


Reply to this email directly or view it on GitHub.

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

7 participants