marko-js / fastify Goto Github PK
View Code? Open in Web Editor NEWRender Marko templates in a Fastify application.
License: MIT License
Render Marko templates in a Fastify application.
License: MIT License
I am unable to render templates with this library and fastify.
No error, template rendered.
The following error occurs:
SyntaxError: Unexpected token '<'
Simply following the example from the readme.
Created a typescript project with fastify, marko v5 and this library.
package.json:
{
"dependencies": {
"@marko/fastify": "^1.0.2",
"fastify": "^3.14.0",
"marko": "^5.5.2",
"tslib": "^2.1.0",
}
}
index.ts:
import Fastify from "fastify";
import markoPlugin from "@marko/fastify";
import Hello from "./templates/hello.marko";
const app = Fastify().register(markoPlugin);
app.get('/', (req: any, reply: any) => {
reply.marko(Hello, {})
})
app.listen(3000, (err: any) => {
if (err) throw err
console.log(`server listening`)
})
hello.marko:
<div>
Hello world
</div>
templates/hello.marko:1
<div>
^
SyntaxError: Unexpected token '<'
at Object.compileFunction (node:vm:355:18)
at wrapSafe (node:internal/modules/cjs/loader:1022:15)
at Module._compile (node:internal/modules/cjs/loader:1056:27)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1121:10)
at Module.load (node:internal/modules/cjs/loader:972:32)
at Function.Module._load (node:internal/modules/cjs/loader:813:14)
at Module.require (node:internal/modules/cjs/loader:996:19)
at require (node:internal/modules/cjs/helpers:92:18)
at Object.<anonymous> (/index.js:5:23)
at Module._compile (node:internal/modules/cjs/loader:1092:14)
Example fails with TypeError [ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension ".marko" for <path to template.marko>
rendered Marko when calling server
Run the example in README, in the above environment.
The fastify server currently waits till the entire stream is done till it starts sending to the client. This causes any <await(promise) client-reorder=true> tag to be shipped, already fullfilled, negating any benefit.
As with the express plugin, streaming should start as soon as possible. Any await tags with reordering should also get sent out, with the stream staying open till the promises finish up serverside
The server stalls till the stream is completed, only then starting to send it to the client.
Repro Repo
^ this repo also includes the fix to try out
In template.marko ${out.global} works perfect.
But how can I get global out in component.js?
I've tried
console.log(window.locals);
console.log(window.out);
and so on, but alas...
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.