{"id":14989635,"url":"https://github.com/tunnckocore/koa-bel","last_synced_at":"2026-02-21T01:01:29.482Z","repository":{"id":66132810,"uuid":"70366138","full_name":"tunnckoCore/koa-bel","owner":"tunnckoCore","description":"View engine for `koa` without any deps, built to be used with `bel`. Any other engines that can be written in `.js` files would work, too. For example, js file template can just return a stream :)","archived":false,"fork":false,"pushed_at":"2020-07-13T21:41:21.000Z","size":23,"stargazers_count":3,"open_issues_count":2,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-01T21:44:47.833Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/tunnckoCore.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"ko_fi":"tunnckoCore","patreon":"tunnckoCore","github":["tunnckoCore"],"custom":["https://gum.co/tunnckoCoreRecurringDonation","https://gum.co/tunnckocorePatronLicense"]}},"created_at":"2016-10-09T00:59:43.000Z","updated_at":"2019-07-16T07:45:27.000Z","dependencies_parsed_at":null,"dependency_job_id":"e40deafa-20a2-4a36-88dc-42c4a1004c9d","html_url":"https://github.com/tunnckoCore/koa-bel","commit_stats":{"total_commits":9,"total_committers":1,"mean_commits":9.0,"dds":0.0,"last_synced_commit":"0c023aa9b605b7fc54cf8f2391efdcc5f5981907"},"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tunnckoCore%2Fkoa-bel","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tunnckoCore%2Fkoa-bel/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tunnckoCore%2Fkoa-bel/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tunnckoCore%2Fkoa-bel/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tunnckoCore","download_url":"https://codeload.github.com/tunnckoCore/koa-bel/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247369953,"owners_count":20927928,"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-09-24T14:18:40.992Z","updated_at":"2025-10-20T07:28:42.970Z","avatar_url":"https://github.com/tunnckoCore.png","language":"JavaScript","funding_links":["https://ko-fi.com/tunnckoCore","https://patreon.com/tunnckoCore","https://github.com/sponsors/tunnckoCore","https://gum.co/tunnckoCoreRecurringDonation","https://gum.co/tunnckocorePatronLicense"],"categories":[],"sub_categories":[],"readme":"# [koa-bel][author-www-url] [![npmjs.com][npmjs-img]][npmjs-url] [![The MIT License][license-img]][license-url] [![npm downloads][downloads-img]][downloads-url] \n\n\u003e View engine for `koa` without any deps, built to be used with `bel`. Any other engines that can be written in `.js` files would work, too.\n\n[![code climate][codeclimate-img]][codeclimate-url] [![standard code style][standard-img]][standard-url] [![travis build status][travis-img]][travis-url] [![coverage status][coveralls-img]][coveralls-url] [![dependency status][david-img]][david-url]\n\n## Install\n\n```\nnpm i koa-bel --save\n```\n\n## Usage\n\u003e For more use-cases see the [tests](./test.js)\n\n```js\nconst koaBel = require('koa-bel')\n```\n\n### [koaBel](index.js#L58)\n\u003e Javascript template views for [koa][]@2. You can use [koa-convert][] if you want to work in koa@1.x version.\n\n\u003e Cool thing about that, is it not requires your\ntemplates to be [bel][] or something other like [yo-yo][],\nor any other DOM thingy. You can simple return a stream\nor buffer or anything that can be added to `ctx.body`.\nBy default it calls `.toString()` on the returned value, but\nyou can bypass that if you pass `opts.toString: false` option.\n\n**Params**\n\n* `\u003cdir\u003e` **{String|Buffer}**: directory to read the views    \n* `[opts]` **{Object}**: optional options    \n* `returns` **{Function}**: plugin for **[koa][] version 2**  \n\n**Example**\n\n```js\nconst Koa = require('koa')\nconst bel = require('koa-bel')\nconst app = new Koa()\n\nconst port = 4290\n\napp.use(bel('./views'))\napp.use((ctx, next) =\u003e {\n  ctx.render('home', {\n    heading: 'Welcome page',\n    description: 'This is our cool landing page, man!',\n    subhead: 'What we offer?',\n    services: [\n      'Realtime Web Apps',\n      'Security and Simplicity',\n      'Logo Design and Prototypes'\n    ]\n  })\n  return next()\n})\n\napp.listen(port, (err) =\u003e {\n  console.log(`Server start listening on http://localhost:${port}`)\n})\n```\n\n**Example `views/home.js`**\n\n\u003e Here you can even use [yo-yo][], instead of [bel][]. Or just return\na buffer or stream and just pass `options.toString: false` option.\n\n```js\n'use strict'\n\nvar bel = require('bel')\n\nmodule.exports = function home (state) {\n  return bel`\u003csection\u003e\n    \u003ch1\u003e${state.heading}\u003c/h1\u003e\n    \u003cp\u003e${state.description}\u003c/p\u003e\n    \u003ch2\u003e${state.subhead}\u003c/h2\u003e\n    \u003cul\u003e${state.services.map((service) =\u003e {\n      return bel`\u003cli\u003e${service}\u003c/li\u003e`\n    })}\u003c/ul\u003e\n  \u003c/section\u003e`\n}\n```\n\n## Related\n- [bash-glob](https://www.npmjs.com/package/bash-glob): Bash-powered globbing for node.js | [homepage](https://github.com/jonschlinkert/bash-glob \"Bash-powered globbing for node.js\")\n- [bel](https://www.npmjs.com/package/bel): A simple extension to native elements | [homepage](https://github.com/shama/bel \"A simple extension to native elements\")\n- [choo](https://www.npmjs.com/package/choo): A 5kb framework for creating sturdy frontend applications | [homepage](https://github.com/yoshuawuyts/choo#readme \"A 5kb framework for creating sturdy frontend applications\")\n- [ip-filter](https://www.npmjs.com/package/ip-filter): Validates valid IPs (IPv4 and IPv6) using [micromatch][] - glob patterns, RegExp… [more](https://github.com/tunnckocore/ip-filter#readme) | [homepage](https://github.com/tunnckocore/ip-filter#readme \"Validates valid IPs (IPv4 and IPv6) using [micromatch][] - glob patterns, RegExp, string or array of globs. If match returns the IP, otherwise null.\")\n- [is-match-ip](https://www.npmjs.com/package/is-match-ip): Matching IPs using [micromatch][] and [ip-filter][] - glob patterns, RegExp, string or… [more](https://github.com/tunnckocore/is-match-ip#readme) | [homepage](https://github.com/tunnckocore/is-match-ip#readme \"Matching IPs using [micromatch][] and [ip-filter][] - glob patterns, RegExp, string or array of globs. Returns matcher function.\")\n- [koa-better-body](https://www.npmjs.com/package/koa-better-body): Full-featured [koa][] body parser! Support parsing text, buffer, json, json patch, json… [more](https://github.com/tunnckocore/koa-better-body#readme) | [homepage](https://github.com/tunnckocore/koa-better-body#readme \"Full-featured [koa][] body parser! Support parsing text, buffer, json, json patch, json api, csp-report, multipart, form and urlencoded bodies. Works for koa@1, koa@2 and will work for koa@3.\")\n- [koa-ip-filter](https://www.npmjs.com/package/koa-ip-filter): Middleware for [koa][] that filters IPs against glob patterns, RegExp, string or… [more](https://github.com/tunnckocore/koa-ip-filter#readme) | [homepage](https://github.com/tunnckocore/koa-ip-filter#readme \"Middleware for [koa][] that filters IPs against glob patterns, RegExp, string or array of globs. Support custom `403 Forbidden` message and custom ID.\")\n- [koa](https://www.npmjs.com/package/koa): Koa web app framework | [homepage](https://github.com/koajs/koa#readme \"Koa web app framework\")\n- [micromatch](https://www.npmjs.com/package/micromatch): Glob matching for javascript/node.js. A drop-in replacement and faster alternative to minimatch… [more](https://github.com/jonschlinkert/micromatch) | [homepage](https://github.com/jonschlinkert/micromatch \"Glob matching for javascript/node.js. A drop-in replacement and faster alternative to minimatch and multimatch.\")\n- [morphdom](https://www.npmjs.com/package/morphdom): Morph a DOM tree to another DOM tree (no virtual DOM needed) | [homepage](https://github.com/patrick-steele-idem/morphdom#readme \"Morph a DOM tree to another DOM tree (no virtual DOM needed)\")\n- [nanomatch](https://www.npmjs.com/package/nanomatch): Fast, minimal glob matcher for node.js. Similar to micromatch, minimatch and multimatch… [more](https://github.com/jonschlinkert/nanomatch) | [homepage](https://github.com/jonschlinkert/nanomatch \"Fast, minimal glob matcher for node.js. Similar to micromatch, minimatch and multimatch, but complete Bash 4.3 wildcard support only (no support for exglobs, posix brackets or braces)\")\n- [vel](https://www.npmjs.com/package/vel): Create and render virtual-dom elements with ease | [homepage](https://github.com/yoshuawuyts/vel#readme \"Create and render virtual-dom elements with ease\")\n- [yo-yo](https://www.npmjs.com/package/yo-yo): A tiny library for building modular UI components using DOM diffing and… [more](https://github.com/maxogden/yo-yo#readme) | [homepage](https://github.com/maxogden/yo-yo#readme \"A tiny library for building modular UI components using DOM diffing and ES6 tagged template literals\")\n\n## Contributing\nPull requests and stars are always welcome. For bugs and feature requests, [please create an issue](https://github.com/tunnckoCore/koa-bel/issues/new).  \nBut before doing anything, please read the [CONTRIBUTING.md](./CONTRIBUTING.md) guidelines.\n\n## [Charlike Make Reagent](http://j.mp/1stW47C) [![new message to charlike][new-message-img]][new-message-url] [![freenode #charlike][freenode-img]][freenode-url]\n\n[![tunnckoCore.tk][author-www-img]][author-www-url] [![keybase tunnckoCore][keybase-img]][keybase-url] [![tunnckoCore npm][author-npm-img]][author-npm-url] [![tunnckoCore twitter][author-twitter-img]][author-twitter-url] [![tunnckoCore github][author-github-img]][author-github-url]\n\n[bel]: https://github.com/shama/bel\n[ip-filter]: https://github.com/tunnckocore/ip-filter\n[koa-convert]: https://github.com/gyson/koa-convert\n[koa]: https://github.com/koajs/koa\n[micromatch]: https://github.com/jonschlinkert/micromatch\n[yo-yo]: https://github.com/maxogden/yo-yo\n\n[npmjs-url]: https://www.npmjs.com/package/koa-bel\n[npmjs-img]: https://img.shields.io/npm/v/koa-bel.svg?label=koa-bel\n\n[license-url]: https://github.com/tunnckoCore/koa-bel/blob/master/LICENSE\n[license-img]: https://img.shields.io/npm/l/koa-bel.svg\n\n[downloads-url]: https://www.npmjs.com/package/koa-bel\n[downloads-img]: https://img.shields.io/npm/dm/koa-bel.svg\n\n[codeclimate-url]: https://codeclimate.com/github/tunnckoCore/koa-bel\n[codeclimate-img]: https://img.shields.io/codeclimate/github/tunnckoCore/koa-bel.svg\n\n[travis-url]: https://travis-ci.org/tunnckoCore/koa-bel\n[travis-img]: https://img.shields.io/travis/tunnckoCore/koa-bel/master.svg\n\n[coveralls-url]: https://coveralls.io/r/tunnckoCore/koa-bel\n[coveralls-img]: https://img.shields.io/coveralls/tunnckoCore/koa-bel.svg\n\n[david-url]: https://david-dm.org/tunnckoCore/koa-bel\n[david-img]: https://img.shields.io/david/tunnckoCore/koa-bel.svg\n\n[standard-url]: https://github.com/feross/standard\n[standard-img]: https://img.shields.io/badge/code%20style-standard-brightgreen.svg\n\n[author-www-url]: http://www.tunnckocore.tk\n[author-www-img]: https://img.shields.io/badge/www-tunnckocore.tk-fe7d37.svg\n\n[keybase-url]: https://keybase.io/tunnckocore\n[keybase-img]: https://img.shields.io/badge/keybase-tunnckocore-8a7967.svg\n\n[author-npm-url]: https://www.npmjs.com/~tunnckocore\n[author-npm-img]: https://img.shields.io/badge/npm-~tunnckocore-cb3837.svg\n\n[author-twitter-url]: https://twitter.com/tunnckoCore\n[author-twitter-img]: https://img.shields.io/badge/twitter-@tunnckoCore-55acee.svg\n\n[author-github-url]: https://github.com/tunnckoCore\n[author-github-img]: https://img.shields.io/badge/github-@tunnckoCore-4183c4.svg\n\n[freenode-url]: http://webchat.freenode.net/?channels=charlike\n[freenode-img]: https://img.shields.io/badge/freenode-%23charlike-5654a4.svg\n\n[new-message-url]: https://github.com/tunnckoCore/ama\n[new-message-img]: https://img.shields.io/badge/ask%20me-anything-green.svg\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftunnckocore%2Fkoa-bel","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftunnckocore%2Fkoa-bel","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftunnckocore%2Fkoa-bel/lists"}