Skip to content

Latest commit

 

History

11 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

quaint-coffeescript

Allows inline CoffeeScript code in Quaint markup.

Expressions in curly brackets will be evaluated in CoffeeScript.

Install

quaint --setup coffeescript

Usage

2 + 2 is {2 + 2}

API

var quaint = require("quaint");
var qcs = require("quaint-coffeescript");

var q = quaint(qcs);

q.toHTML("2 + 3 = {2 + 3}");
// ==> "2 + 3 = 5"

Functionality

In embedded CoffeeScript, you can use the h function to create HTML elements programmatically:

q.toHTML("{h 'a.cls#id', href: 'there', 'A', 'B'}");
// ==> '<a href="there" id="id" class="cls">AB</a>'

q.toHTML("{[(h "b", i * i) for i in [1, 2, 3]]}");
// ==> "<b>1</b><b>4</b><b>9</b>"

Options

sandbox

An object to use as the global object for eval. All the properties you set on that object will be available as top level variables in scripts.

vm

The module to use for the virtualization (defaults to the standard vm module, so you usally won't have to set it).

The module must implement these two methods:

  • vm.createContext(sandbox): "contextify" the object, i.e. make it into a proper environment for the evaluator. If you implement your own, you return the sandbox itself, or a copy.

  • vm.runInContext(code, sandbox): evaluate the code in the sandbox returned by createContext.

About

Embed CoffeeScript in Quaint markup

Topics

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors