Skip to content

Commit

Permalink
Register inheritance tags.
Browse files Browse the repository at this point in the history
  • Loading branch information
jg-rp committed Aug 2, 2023
1 parent 233bf09 commit a40d8b1
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 2 deletions.
30 changes: 30 additions & 0 deletions src/extra/register.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { Environment } from "../environment";
import {
BlockTag,
CallTag,
ConditionalOutputStatementWithParens,
ConditionalAssignTagWithParens,
ConditionalEchoTagWithParens,
ExtendsTag,
IfNotTag,
MacroTag,
WithTag,
} from "./tags";

export function registerInheritanceTags(env: Environment): void {
env.tags["block"] = new BlockTag();
env.tags["extends"] = new ExtendsTag();
}

export function registerExtras(env: Environment): void {
registerInheritanceTags(env);
env.tags["call"] = new CallTag();
env.tags["ConditionalOutputStatementWithParens"] =
new ConditionalOutputStatementWithParens();
env.tags["ConditionalAssignTagWithParens"] =
new ConditionalAssignTagWithParens();
env.tags["ConditionalEchoTagWithParens"] = new ConditionalEchoTagWithParens();
env.tags["IfNotTag"] = new IfNotTag();
env.tags["MacroTag"] = new MacroTag();
env.tags["WithTag"] = new WithTag();
}
4 changes: 2 additions & 2 deletions tests/tags/extra/extends.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
LiquidUndefinedError,
TemplateInheritanceError,
} from "../../../src/errors";
import { registerInheritanceTags } from "../../../src/extra/register";
import { StrictUndefined } from "../../../src/undefined";

type Case = {
Expand Down Expand Up @@ -283,8 +284,7 @@ describe("template inheritance", () => {
globals,
loader: new ObjectLoader(partials),
});
env.addTag("extends", new ExtendsTag());
env.addTag("block", new BlockTag());
registerInheritanceTags(env);
const template = env.fromString(source);
const result = await template.render();
expect(result).toBe(want);
Expand Down

0 comments on commit a40d8b1

Please sign in to comment.