Skip to content

Commit

Permalink
feat(platform-views): give root option to the engine to fix Eta views…
Browse files Browse the repository at this point in the history
… dir support
  • Loading branch information
Romakita committed Feb 22, 2024
1 parent 11eff10 commit e2fd44d
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export const PLATFORM_VIEWS_EXTENSIONS = {
dot: "dot",
dust: "dust",
ect: "ect",
eta: "eta",
ejs: "ejs",
haml: "haml",
"haml-coffee": "haml-coffee",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ describe("PlatformViews", () => {
cache: false,
alter: "alter",
global: "global",
requires: "requires"
requires: "requires",
root: expect.any(String)
});
});
it("should render a template without extension", async () => {
Expand All @@ -63,7 +64,8 @@ describe("PlatformViews", () => {
global: "global",
test: "test",
alter: "alter",
requires: "requires"
requires: "requires",
root: expect.any(String)
});
});
it("should render a template without extension", async () => {
Expand Down
12 changes: 11 additions & 1 deletion packages/platform/platform-views/src/services/PlatformViews.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,17 @@ export class PlatformViews {
throw new Error(`Engine not found to render the following "${viewPath}"`);
}

const finalOpts = Object.assign({cache: this.cache || this.env === Env.PROD}, engine.options, options, {$ctx});
const finalOpts = Object.assign(
{
cache: this.cache || this.env === Env.PROD
},
engine.options,
options,
{
$ctx,
root: this.root
}
);

return engine.render(path, finalOpts);
}
Expand Down

0 comments on commit e2fd44d

Please sign in to comment.