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

Split out template engine into “x-template.js”. #227

Merged
merged 1 commit into from
Dec 5, 2024

Conversation

theengineear
Copy link
Collaborator

Conceptually “XElement” and “XTemplate” do very different things. The former is all about defining element interfaces and the latter is all about turning interpolated markup into dom.

Over time, even our PR diffs have highlited this separation of concerns. Often a PR either changes XElement or XTemplate — rarely both.

"./etc/ready.js"
],
"compilerOptions": {
"target": "ES2023",
// Beyond just organization, a “bug” in how JSDocs works causes a cyclic
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was a cute one. It’s not really a bug from the perspective of the maintainers. Not terribly hard to workaround though — we just throw things into a /ts directory. Maybe we should have just done that from the start 🤷

Without this… you could build the types exactly once. Repeat builds would confuse TypeScript since the filename prefixes are the same. I.e., it would think we were trying to import our export 🤖

}

// Long-term interface.
export const render = TemplateEngine.interface.render.bind(TemplateEngine);
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rather than export the class (which would lend itself to potential extension / misuse)… we export the exact functions in the interface (many of which are soon to be deleted!).

Conceptually “XElement” and “XTemplate” do very different things. The
former is all about defining _element interfaces_ and the latter is all
about turning interpolated markup into dom.

Over time, even our PR diffs have highlited this separation of concerns.
Often a PR _either_ changes XElement _or_ XTemplate — rarely both.
@theengineear theengineear force-pushed the split-out-template-engine branch from 2213dfc to 3aa78b3 Compare December 5, 2024 04:24
@theengineear
Copy link
Collaborator Author

FYI @klebba — Just working through some of the decisions we’ve been chatting about. In this case, we agreed that splitting this into two files is probably the right move. I went ahead and bumped some dev dependencies as well.

@theengineear theengineear merged commit 41f4e87 into main Dec 5, 2024
1 check passed
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.

1 participant