Giter VIP home page Giter VIP logo

quaint-javascript's Introduction

quaint-javascript

Allows inline JavaScript code in Quaint markup.

Expressions in curly brackets will be evaluated in JavaScript.

Install

quaint --setup javascript

Usage

2 + 2 is {2 + 2}

API

var quaint = require("quaint");
var qjs = require("quaint-javascript");

var q = quaint(qjs);

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

Functionality

In embedded JavaScript, 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("{[1, 2, 3].map(function (x) { return h('b', x); })}")
// ==> "<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.

transform

A function to use to preprocess the code before evaluating it. This could be a compiler, for example.

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.

quaint-javascript's People

Contributors

breuleux avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.