Socket
Socket
Sign inDemoInstall

jade-code-gen

Package Overview
Dependencies
19
Maintainers
5
Versions
4
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    jade-code-gen

Default code-generator for jade. It generates HTML via a JavaScript template function.


Version published
Weekly downloads
5
increased by400%
Maintainers
5
Install size
5.32 MB
Created
Weekly downloads
 

Readme

Source

jade-code-gen

Default code-generator for jade. It generates HTML via a JavaScript template function.

Build Status Dependency Status NPM version

Installation

npm install jade-code-gen

Usage

var generateCode = require('jade-code-gen');

generateCode(ast, options)

Generate a JavaScript function string for the given AST.

ast is a fully expanded AST for Jade, with all inclusion, extends, and filters resolved.

options may contain the following properties that have the same meaning as the options with the same names in jade:

  • pretty (boolean): default is false
  • compileDebug (boolean): default is false
  • doctype (string): default is undefined
  • inlineRuntimeFunctions (boolean): default is false
  • globals (array of strings): default is []
  • self (boolean): default is false

In addition to above, jade-code-gen has the following unique options:

  • includeSources (object): map of filename to source string; used if compileDebug is true; default is undefined
  • templateName (string): the name of the generated function; default is 'template'
var lex = require('jade-lexer');
var parse = require('jade-parser');
var generateCode = require('jade-code-gen');

var funcStr = generateCode(parse(lex('p Hello world!')), {
  compileDebug: false,
  pretty: true,
  inlineRuntimeFunctions: false,
  templateName: 'helloWorld'
});

var func = Function('locals', funcStr);
func();
//=> '\n<p>Hello world!</p>'

new generateCode.CodeGenerator(ast, options)

The constructor for the internal class of the code generator. You shouldn't need to use this for most purposes.

License

MIT

Keywords

FAQs

Last updated on 14 Nov 2015

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc