-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
75 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { Eta } from "eta"; | ||
const eta = new Eta(); | ||
|
||
export const compile = { | ||
server(text) { | ||
return ` | ||
import { Eta } from "eta"; | ||
const eta = new Eta(); | ||
${eta.compile(text).toString()} | ||
export default (props, options) => anonymous.call(eta, props, options); | ||
`; | ||
}, | ||
}; | ||
|
||
export const render = (component, props) => component(props); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import * as O from "rcompat/object"; | ||
import { compile, peers, load } from "../common/exports.js"; | ||
import depend from "../depend.js"; | ||
|
||
const handler = ({ directory, render }) => (name, props = {}, options = {}) => | ||
async app => { | ||
const components = app.runpath(app.get("location.server"), directory); | ||
const { default : component } = await load(components.join(name)); | ||
|
||
return app.view({ body: render(component, props), ...options }); | ||
}; | ||
|
||
const name = "eta"; | ||
const dependencies = ["eta"]; | ||
const default_extension = ".eta"; | ||
const on = O.filter(peers, ([key]) => dependencies.includes(key)); | ||
|
||
export default ({ extension = default_extension } = {}) => { | ||
const rootname = name; | ||
|
||
return { | ||
name: `primate:${name}`, | ||
async init(app, next) { | ||
await depend(on, `frontend:${name}`); | ||
|
||
const imports = await import("./imports.js"); | ||
|
||
app.register(extension, { | ||
handle: handler({ | ||
directory: app.get("location.components"), | ||
render: imports.render, | ||
}), | ||
compile: { | ||
...await compile({ | ||
app, | ||
extension, | ||
rootname, | ||
compile: imports.compile, | ||
}), | ||
// no support for hydration | ||
client: _ => _, | ||
}, | ||
}); | ||
|
||
return next(app); | ||
}, | ||
}; | ||
}; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,11 @@ | ||
export { default as webc } from "./webc/module.js"; | ||
export { default as angular } from "./angular/module.js"; | ||
export { default as eta } from "./eta/module.js"; | ||
export { default as handlebars } from "./handlebars/module.js"; | ||
export { default as htmx } from "./htmx/module.js"; | ||
export { default as markdown } from "./markdown/module.js"; | ||
export { default as marko } from "./marko/module.js"; | ||
export { default as react } from "./react/module.js"; | ||
export { default as solid } from "./solid/module.js"; | ||
export { default as svelte } from "./svelte/module.js"; | ||
export { default as vue } from "./vue/module.js"; | ||
export { default as angular } from "./angular/module.js"; | ||
export { default as handlebars } from "./handlebars/module.js"; | ||
export { default as marko } from "./marko/module.js"; | ||
export { default as webc } from "./webc/module.js"; |