{"id":20083660,"url":"https://github.com/marko-js/express","last_synced_at":"2025-07-30T23:09:33.589Z","repository":{"id":54323555,"uuid":"287363183","full_name":"marko-js/express","owner":"marko-js","description":"Render Marko templates in an express application.","archived":false,"fork":false,"pushed_at":"2022-11-03T22:53:27.000Z","size":345,"stargazers_count":9,"open_issues_count":0,"forks_count":2,"subscribers_count":5,"default_branch":"main","last_synced_at":"2025-04-26T00:03:36.825Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/marko-js.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":".github/CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-08-13T19:25:04.000Z","updated_at":"2024-01-07T04:37:58.000Z","dependencies_parsed_at":"2022-08-13T12:00:53.966Z","dependency_job_id":null,"html_url":"https://github.com/marko-js/express","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marko-js%2Fexpress","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marko-js%2Fexpress/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marko-js%2Fexpress/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marko-js%2Fexpress/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/marko-js","download_url":"https://codeload.github.com/marko-js/express/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252604282,"owners_count":21775077,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-13T15:48:21.401Z","updated_at":"2025-05-06T01:31:26.626Z","avatar_url":"https://github.com/marko-js.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003ch1 align=\"center\"\u003e\n  \u003c!-- Logo --\u003e\n  \u003cbr/\u003e\n  @marko/express\n\t\u003cbr/\u003e\n\n  \u003c!-- Language --\u003e\n  \u003ca href=\"http://typescriptlang.org\"\u003e\n    \u003cimg src=\"https://img.shields.io/badge/%3C%2F%3E-typescript-blue.svg\" alt=\"TypeScript\"/\u003e\n  \u003c/a\u003e\n  \u003c!-- Format --\u003e\n  \u003ca href=\"https://github.com/prettier/prettier\"\u003e\n    \u003cimg src=\"https://img.shields.io/badge/styled_with-prettier-ff69b4.svg\" alt=\"Styled with prettier\"/\u003e\n  \u003c/a\u003e\n  \u003c!-- CI --\u003e\n  \u003ca href=\"https://github.com/marko-js/express/actions/workflows/ci.yml\"\u003e\n    \u003cimg src=\"https://github.com/marko-js/express/actions/workflows/ci.yml/badge.svg\" alt=\"Build status\"/\u003e\n  \u003c/a\u003e\n  \u003c!-- Coverage --\u003e\n  \u003ca href=\"https://codecov.io/gh/marko-js/express\"\u003e\n    \u003cimg src=\"https://codecov.io/gh/marko-js/express/branch/main/graph/badge.svg?token=KWZ4YNTZVY\"/\u003e\n  \u003c/a\u003e\n  \u003c!-- NPM Version --\u003e\n  \u003ca href=\"https://npmjs.org/package/@marko/express\"\u003e\n    \u003cimg src=\"https://img.shields.io/npm/v/@marko/express.svg\" alt=\"NPM Version\"/\u003e\n  \u003c/a\u003e\n  \u003c!-- Downloads --\u003e\n  \u003ca href=\"https://npmjs.org/package/@marko/express\"\u003e\n    \u003cimg src=\"https://img.shields.io/npm/dm/@marko/express.svg\" alt=\"Downloads\"/\u003e\n  \u003c/a\u003e\n\u003c/h1\u003e\n\nRender [Marko](https://markojs.com/) templates in an [`express`](http://expressjs.com/) application.\n\n# Installation\n\n```console\nnpm install @marko/express\n```\n\n# Examples\n\n## Setup\n\n```javascript\nimport express from \"express\";\nimport markoMiddleware from \"@marko/express\";\nimport Template from \"./template.marko\";\n\nconst app = express();\n\napp.use(markoMiddleware());\n\napp.get(\"/\", (req, res) =\u003e {\n  // Streams Marko template into the response.\n  // Forwards errors into expresses error handler.\n  res.marko(Template, { hello: \"world\" });\n});\n```\n\n## $global / out.global\n\nWhen calling `res.marko` the [`input.$global`](https://markojs.com/docs/rendering/#global-data) is automatically merged with [`app.locals`](http://expressjs.com/en/5x/api.html#app.locals) and [`res.locals`](http://expressjs.com/en/5x/api.html#res.locals) from [`express`](http://expressjs.com/). This makes it easy to set some global data via express middleware, eg:\n\n_middleware.js_\n\n```js\nexport default (req, res, next) =\u003e {\n  res.locals.locale = \"en-US\";\n};\n```\n\nThen later in a template access via:\n\n```marko\n\u003cdiv\u003e${out.global.locale}\u003c/div\u003e\n```\n\n## Redirects\n\nAllows `res.redirect` to redirect HTML responses that have already begun sending content. This is done by flushing a `\u003cmeta\u003e` tag redirect with a `\u003cscript\u003e` fallback before prematurely ending the response.\n\nIf `$global` includes a `cspNonce` it will be included in the redirect script.\n\n```js\napp.get(\"/\", (req, res) =\u003e {\n  res.marko(Template, { $global: { cspNonce: \"xyz\" } });\n\n  // If a redirect occurs mid stream we'll see\n  // something like the following in the output:\n  //\n  // \u003cmeta http-equiv=refresh content=\"0;url=...\"\u003e\n  // \u003cscript nonce=\"xyz\"\u003elocation.href=\"...\"\u003e\u003c/script\u003e\n});\n```\n\n# Code of Conduct\n\nThis project adheres to the [eBay Code of Conduct](./.github/CODE_OF_CONDUCT.md). By participating in this project you agree to abide by its terms.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarko-js%2Fexpress","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmarko-js%2Fexpress","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarko-js%2Fexpress/lists"}