koa-bel
View engine for
koa
without any deps, built to be used withbel
. Any other engines that can be written in.js
files would work, too.
Install
npm i koa-bel --save
Usage
For more use-cases see the tests
const koaBel =
koaBel
Javascript template views for koa@2. You can use koa-convert if you want to work in koa@1.x version.
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
. By default it calls.toString()
on the returned value, but you can bypass that if you passopts.toString: false
option.
Params
<dir>
{String|Buffer}: directory to read the views[opts]
{Object}: optional optionsreturns
{Function}: plugin for koa version 2
Example
const Koa = const bel = const app = const port = 4290 appapp app
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.
'use strict' var bel = module { return bel`<section> <h1></h1> <p></p> <h2></h2> <ul></ul> </section>`}
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
- 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 | 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 | homepage
Contributing
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.