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

drop support for marko #289

Merged
merged 1 commit into from
Dec 22, 2021
Merged
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
5 changes: 1 addition & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -129,11 +129,8 @@ yarn.lock
.vscode
.idea

# marko generated files
*.marko.js

# temporary/work/output folders
# build/
out
temp/
tmp/
tmp/
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ Currently supports the following templates engines:
- [`nunjucks`](https://mozilla.github.io/nunjucks/)
- [`pug`](https://pugjs.org/api/getting-started.html)
- [`handlebars`](https://handlebarsjs.com/)
- [`marko`](https://markojs.com/)
- [`mustache`](https://mustache.github.io/)
- [`art-template`](https://aui.github.io/art-template/)
- [`twig`](https://twig.symfony.com/)
Expand All @@ -29,6 +28,8 @@ _Note that at least Fastify `v2.0.0` is needed._

_Note: [`ejs-mate`](https://github.com/JacksonTian/ejs-mate) support [has been dropped](https://github.com/fastify/point-of-view/pull/157)._

_Note: [`marko`](https://markojs.com/) support has been dropped. Please use [`@marko/fastify`](https://github.com/marko-js/fastify) instead._

#### Benchmarks

The benchmark were run with the files in the `benchmark` folder with the `ejs` engine.
Expand Down
56 changes: 0 additions & 56 deletions example-marko.js

This file was deleted.

1 change: 0 additions & 1 deletion index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ export interface PointOfViewOptions {
nunjucks?: any;
pug?: any;
handlebars?: any;
marko?: any;
mustache?: any;
'art-template'?: any;
twig?: any;
Expand Down
41 changes: 1 addition & 40 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const resolve = require('path').resolve
const join = require('path').join
const { basename, dirname, extname } = require('path')
const HLRU = require('hashlru')
const supportedEngines = ['ejs', 'nunjucks', 'pug', 'handlebars', 'marko', 'mustache', 'art-template', 'twig', 'liquid', 'dot', 'eta']
const supportedEngines = ['ejs', 'nunjucks', 'pug', 'handlebars', 'mustache', 'art-template', 'twig', 'liquid', 'dot', 'eta']

function fastifyView (fastify, opts, next) {
if (!opts.engine) {
Expand Down Expand Up @@ -58,7 +58,6 @@ function fastifyView (fastify, opts, next) {
const dotRender = type === 'dot' ? viewDot.call(fastify, preProcessDot.call(fastify, templatesDir, globalOptions)) : null

const renders = {
marko: viewMarko,
ejs: withLayout(viewEjs, globalLayoutFileName),
handlebars: withLayout(viewHandlebars, globalLayoutFileName),
mustache: viewMustache,
Expand Down Expand Up @@ -392,44 +391,6 @@ function fastifyView (fastify, opts, next) {
})
}

function viewMarko (page, data, opts) {
if (!page) {
this.send(new Error('Missing page'))
return
}

data = Object.assign({}, defaultCtx, this.locals, data)
// append view extension
page = getPage(page, type)

// Support compile template from memory
// opts.templateSrc : string - pre-loaded template source
// even to load from memory, a page parameter still should be provided and the parent path should exist for the loader to search components along the path.

const template = opts && opts.templateSrc ? engine.load(join(templatesDir, page), opts.templateSrc) : engine.load(join(templatesDir, page))

if (opts && opts.stream) {
if (typeof globalOptions.useHtmlMinifyStream === 'function') {
this.send(template.stream(data).pipe(globalOptions.useHtmlMinifyStream(globalOptions.htmlMinifierOptions || {})))
} else {
this.send(template.stream(data))
}
} else {
template.renderToString(data, send(this))
}

function send (that) {
return function _send (err, html) {
if (err) return that.send(err)
if (globalOptions.useHtmlMinifier && (typeof globalOptions.useHtmlMinifier.minify === 'function')) {
html = globalOptions.useHtmlMinifier.minify(html, globalOptions.htmlMinifierOptions || {})
}
that.header('Content-Type', 'text/html; charset=' + charset)
that.send(html)
}
}
}

function viewHandlebars (page, data, opts) {
if (opts && opts.layout) {
try {
Expand Down
7 changes: 0 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
"view",
"speed",
"ejs",
"marko",
"nunjucks",
"pug",
"handlebars",
Expand Down Expand Up @@ -51,7 +50,6 @@
"html-minifier": "^4.0.0",
"html-minify-stream": "^2.0.0",
"liquidjs": "^9.15.1",
"marko": "^5.1.2",
"mustache": "^4.0.1",
"nunjucks": "^3.2.1",
"pino": "^6.7.0",
Expand All @@ -66,11 +64,6 @@
"twig": "^1.13.3",
"typescript": "^4.0.2"
},
"standard": {
"ignore": [
"*.marko.js"
]
},
"tsd": {
"directory": "test"
}
Expand Down
Loading