Skip to content
This repository


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

kup is an html builder for nodejs

branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time


Build Status

kup is an html builder for nodejs


npm install kup


Kup = require 'kup'

k = new Kup


k.html ->
    k.head ->
        k.title 'a title'
            src: ''
            type: 'text/javascript'
    k.body ->
        k.div {id: 'container'}, ->
            k.h1 'a heading'
            k.h2 {class: 'secondary-heading'}, 'another heading'
            k.ul ->
                'first second third'.split(' ').forEach (x) ->
           -> k.a x
            k.p ->
                k.unsafe 'Before the break'
                k.unsafe 'After the break'

console.log k.htmlOut

produces the following html:

<!DOCTYPE html>
<title>a title</title>
<script src="" type="text/javascript"></script>
<div id="container">
<h1>a heading</h1>
<h2 class="secondary-heading">another heading</h2>
<p>Before the break<br />
After the break</p>

xss prevention

kup will html escape text content.

kup will properly quote attributes using double quotes. properly quoted attributes can only be escaped with the corresponding quote. kup escapes all double quotes inside attributes values to prevent escaping.

use the unsafe function to insert inner text which will not be escaped:

k.script ->
    k.unsafe 'javascript which should not be escaped'

use the safe function to insert inner text which will be escaped:

k.p -> 'this will be escaped' 'this will also be escaped'


kup is inspired by mark hahn's drykup

license: MIT

Something went wrong with that request. Please try again.