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

Inline partials are not working #7

Open
MickL opened this issue Apr 11, 2022 · 0 comments
Open

Inline partials are not working #7

MickL opened this issue Apr 11, 2022 · 0 comments

Comments

@MickL
Copy link

MickL commented Apr 11, 2022

Using inline partial as shown here I get an error:

Error: The partial myPartial could not be found

It works if I use the regular handlebars object instead.

Code:

const handlebars = require('handlebars'),
    asyncHelpers = require('handlebars-async-helpers')
const hb = asyncHelpers(handlebars)

hb.registerHelper('sleep', async () => new Promise((resolve) => {
    setTimeout(() => resolve('Done!'), 1000)
}))

async function main() {
    const template = hb.compile(`
    {{#*inline "myPartial"}}
      {{firstname}}
    {{/inline}}
    {{#each people}}
      {{> myPartial this}}
    {{/each}}
    `);
    const result = await template({
            people: [
                {firstname: "Nils"},
                {firstname: "Yehuda"},
            ],
        }
    );
    console.log(result);
}

main();
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