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

Override partial #191

Open
mbalex99 opened this issue Apr 14, 2020 · 0 comments
Open

Override partial #191

mbalex99 opened this issue Apr 14, 2020 · 0 comments

Comments

@mbalex99
Copy link

Great library everyone! I have a problem where I occasionally want use a partial outside of the partials directory

Here's my express server code

app.engine('hbs', hbs.express4({
  defaultLayout: path.resolve(__dirname, "../views/layouts/main.hbs"),
  partialsDir: path.resolve(__dirname, '../views/partials')
}));
app.get('/about/company', (req, res) => {
  res.render('pages/about')
})

I have a directory structure like so:

views/partials/footer.hbs

views/layouts/main.hbs

views/pages/about/index.hbs
views/pages/about/about-only-partial-a.hbs
views/pages/about/about-only-partial-b.hbs

In my about.hbs file, I want to use the main.hbs layout but also reference some local partials (the ones name about-only-partial-a.hbs and about-only-partial-b.hbs

I've tried this code in my about.hbs:

{{> ./about-only-partial-a.hbs}}
{{> ./about-only-partial-b.hbs}}

But I constantly get this error

Error: [pages/about\index.hbs] The partial ./about-only-partial-a could not be found

Is there anyway I can use partials but override it to specify a path?

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

1 participant