-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
How to include js files in Handlebars template #1539
Comments
Can't really help much with these details. Can you post some code showing what you are trying to do or a link to your project? |
I have found the issue. I was actually unable to serve js file in a html file (included but 404) which i was rendering through handlebars. So i made a route for the static folder and now that html file can access the js file. But i would like to have your advise on how i should serve css, images, and js file (custom written) in my html pages. Thanks. I'm a newbie so i was continuously thinking about whether i should create an issue or not. Because my question was a total noob. I am doing my best to adopt it and learn it as fast as i can. So i can recommend it to others. I know a little about the efforts you guys putting in it to make it The Best framework. |
You can serve static files like so: app.js: server.route({
method: 'GET',
path: '/{filename*}',
handler: {
directory: {
path: __dirname + '/public',
listing: false,
index: false
}
}
});
server.route({
method: 'GET',
path: '/',
handler: function(request, reply) {
reply.view('homepage');
}
}); Then any files in the Check out issue #1489 for some getting started guides :) |
Thank you James, this seems to unfortunately be nowhere in the official documentation or tutorials. |
I am using hapi.js as server side framework with handlebars as template engine. I tried including a js (jquery or custom functions) file in simple html page. But 404 message prompting in browser console. I don't really know whether its hapi.js or handlebars issue. Looking for expert advice! Thanks for any help!
The text was updated successfully, but these errors were encountered: