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

Throw error when it can't find a proper template engine #87

Merged
merged 2 commits into from
May 3, 2021

Conversation

fserb
Copy link
Contributor

@fserb fserb commented May 2, 2021

No description provided.

@oscarotero
Copy link
Member

Not sure about this workaround. Not all pages need a template engine.
Maybe it's better a simple if here

lume/site.js

Line 514 in d58edc7

const engine = this.#getEngine(layout);

@fserb
Copy link
Contributor Author

fserb commented May 2, 2021

Not sure if that's what you meant? I understand the first #getEngine doesn't need to exist, but I'm guessing once the person passed a layout, it needs to be on a template engine, right?

If that's not the case, then I think the right thing would probably be to check if the file exists at all.

@oscarotero oscarotero merged commit e279022 into lumeland:master May 3, 2021
@oscarotero
Copy link
Member

oscarotero commented May 3, 2021

It's ok that the first #getEngine returns undefined, and that's why there's a else if in line 535:

lume/site.js

Lines 529 to 537 in 058aa32

const engine = this.#getEngine(page.src.ext, pageData.templateEngine);
if (Array.isArray(engine)) {
for (const eng of engine) {
content = await eng.render(content, pageData, path);
}
} else if (engine) {
content = await engine.render(content, pageData, path);
}

With this change, instead returning undefined, it throws and exception.

Edit: I just realized that you change it and now it's correct. Merging. Thanks!

@fserb fserb deleted the engine-error branch May 3, 2021 18:34
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

Successfully merging this pull request may close these issues.

None yet

2 participants