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

Enhance: use html parser in preprocessor #240

Closed
wants to merge 17 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/Elder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import {
} from './utils/types';
import createReadOnlyProxy from './utils/createReadOnlyProxy';
import workerBuild from './workerBuild';
import { inlineSvelteComponent } from './partialHydration/inlineSvelteComponent';
import inlineComponent from './partialHydration/inlineComponent';
import elderJsShortcodes from './shortcodes';
import prepareRouter from './routes/prepareRouter';

Expand Down Expand Up @@ -219,7 +219,9 @@ class Elder {

this.helpers = {
permalinks: permalinks({ routes: this.routes, settings: this.settings }),
inlineSvelteComponent,
// TODO: deprecate this?
inlineSvelteComponent: inlineComponent,
inlineComponent,
shortcode: prepareInlineShortcode({ settings: this.settings }),
};

Expand Down
2 changes: 2 additions & 0 deletions src/__tests__/__snapshots__/Elder.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Object {
"data": Object {},
"errors": Array [],
"helpers": Object {
"inlineComponent": [Function],
"inlineSvelteComponent": [Function],
"permalinks": Object {
"route-a": [Function],
Expand Down Expand Up @@ -649,6 +650,7 @@ Object {
"data": Object {},
"errors": Array [],
"helpers": Object {
"inlineComponent": [Function],
"inlineSvelteComponent": [Function],
"permalinks": Object {
"route-a": [Function],
Expand Down
20 changes: 20 additions & 0 deletions src/partialHydration/__tests__/inlineComponent.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import inlineComponent from '../inlineComponent';

test('#inlineComponent', () => {
const options = {
loading: 'lazy',
};
expect(
inlineComponent({
name: 'Home',
props: {
welcomeText: 'Hello World',
},
options,
}),
).toMatchInlineSnapshot(
`"<ejswrapper ejs-mount=\\"[&quot;Home&quot;,{&quot;welcomeText&quot;:&quot;Hello World&quot;},{&quot;loading&quot;:&quot;lazy&quot;}]\\"></ejswrapper>"`,
);
// FIXME: should it throw when name is null?
expect(inlineComponent({})).toMatchInlineSnapshot(`"<ejswrapper ejs-mount=\\"[null,null,null]\\"></ejswrapper>"`);
});
46 changes: 0 additions & 46 deletions src/partialHydration/__tests__/inlineSvelteComponent.spec.ts

This file was deleted.

Loading