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.
npm install koa-bel> 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.
[![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]
```
npm i koa-bel --save
`js`
const koaBel = require('koa-bel')
> Cool thing about that, is it not requires your
templates to be [bel][] or something other like [yo-yo][],
or any other DOM thingy. You can simple return a stream
or buffer or anything that can be added to ctx.body..toString()
By default it calls on the returned value, butopts.toString: false
you can bypass that if you pass option.
Params
*
{String|Buffer}: directory to read the views
* [opts] {Object}: optional options
* returns {Function}: plugin for [koa][] version 2 Example
`js
const Koa = require('koa')
const bel = require('koa-bel')
const app = new Koa()const port = 4290
app.use(bel('./views'))
app.use((ctx, next) => {
ctx.render('home', {
heading: 'Welcome page',
description: 'This is our cool landing page, man!',
subhead: 'What we offer?',
services: [
'Realtime Web Apps',
'Security and Simplicity',
'Logo Design and Prototypes'
]
})
return next()
})
app.listen(port, (err) => {
console.log(
Server start listening on http://localhost:${port})
})
`Example
views/home.js> Here you can even use [yo-yo][], instead of [bel][]. Or just return
a buffer or stream and just pass
options.toString: false option.`js
'use strict'var bel = require('bel')
module.exports = function home (state) {
return bel
${state.description}
- ${service}
}
`Related
- bash-glob: Bash-powered globbing for node.js | homepage
- bel: A simple extension to native elements | homepage
- choo: A 5kb framework for creating sturdy frontend applications | homepage
- ip-filter: Validates valid IPs (IPv4 and IPv6) using [micromatch][] - glob patterns, RegExp… more | homepage using [micromatch][] - glob patterns, RegExp, string or array of globs. If match returns the IP, otherwise null.")
- is-match-ip: Matching IPs using [micromatch][] and [ip-filter][] - glob patterns, RegExp, string or… more | homepage
- koa-better-body: Full-featured [koa][] body parser! Support parsing text, buffer, json, json patch, json… more | homepage
- koa-ip-filter: Middleware for [koa][] that filters IPs against glob patterns, RegExp, string or… more | 403 Forbidden` message and custom ID."" class="text-primary hover:underline" target="_blank" rel="noopener noreferrer">homepage
- koa: Koa web app framework | homepage
- micromatch: Glob matching for javascript/node.js. A drop-in replacement and faster alternative to minimatch… more | homepage
- morphdom: Morph a DOM tree to another DOM tree (no virtual DOM needed) | homepage")
- nanomatch: Fast, minimal glob matcher for node.js. Similar to micromatch, minimatch and multimatch… more | homepage")
- vel: Create and render virtual-dom elements with ease | homepage
- yo-yo: A tiny library for building modular UI components using DOM diffing and… more | homepageContributing
Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.
But before doing anything, please read the CONTRIBUTING.md guidelines.Charlike Make Reagent [![new message to charlike][new-message-img]][new-message-url] [![freenode #charlike][freenode-img]][freenode-url]
[![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]
[bel]: https://github.com/shama/bel
[ip-filter]: https://github.com/tunnckocore/ip-filter
[koa-convert]: https://github.com/gyson/koa-convert
[koa]: https://github.com/koajs/koa
[micromatch]: https://github.com/jonschlinkert/micromatch
[yo-yo]: https://github.com/maxogden/yo-yo
[npmjs-url]: https://www.npmjs.com/package/koa-bel
[npmjs-img]: https://img.shields.io/npm/v/koa-bel.svg?label=koa-bel
[license-url]: https://github.com/tunnckoCore/koa-bel/blob/master/LICENSE
[license-img]: https://img.shields.io/npm/l/koa-bel.svg
[downloads-url]: https://www.npmjs.com/package/koa-bel
[downloads-img]: https://img.shields.io/npm/dm/koa-bel.svg
[codeclimate-url]: https://codeclimate.com/github/tunnckoCore/koa-bel
[codeclimate-img]: https://img.shields.io/codeclimate/github/tunnckoCore/koa-bel.svg
[travis-url]: https://travis-ci.org/tunnckoCore/koa-bel
[travis-img]: https://img.shields.io/travis/tunnckoCore/koa-bel/master.svg
[coveralls-url]: https://coveralls.io/r/tunnckoCore/koa-bel
[coveralls-img]: https://img.shields.io/coveralls/tunnckoCore/koa-bel.svg
[david-url]: https://david-dm.org/tunnckoCore/koa-bel
[david-img]: https://img.shields.io/david/tunnckoCore/koa-bel.svg
[standard-url]: https://github.com/feross/standard
[standard-img]: https://img.shields.io/badge/code%20style-standard-brightgreen.svg
[author-www-url]: http://www.tunnckocore.tk
[author-www-img]: https://img.shields.io/badge/www-tunnckocore.tk-fe7d37.svg
[keybase-url]: https://keybase.io/tunnckocore
[keybase-img]: https://img.shields.io/badge/keybase-tunnckocore-8a7967.svg
[author-npm-url]: https://www.npmjs.com/~tunnckocore
[author-npm-img]: https://img.shields.io/badge/npm-~tunnckocore-cb3837.svg
[author-twitter-url]: https://twitter.com/tunnckoCore
[author-twitter-img]: https://img.shields.io/badge/twitter-@tunnckoCore-55acee.svg
[author-github-url]: https://github.com/tunnckoCore
[author-github-img]: https://img.shields.io/badge/github-@tunnckoCore-4183c4.svg
[freenode-url]: http://webchat.freenode.net/?channels=charlike
[freenode-img]: https://img.shields.io/badge/freenode-%23charlike-5654a4.svg
[new-message-url]: https://github.com/tunnckoCore/ama
[new-message-img]: https://img.shields.io/badge/ask%20me-anything-green.svg