Skip to content
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
48 lines (32 sloc) 875 Bytes

Translate AST to string

generate(ast[, options])

Generates a CSS string for given AST.

// generate with default settings

// generate with options
csstree.generate(ast, {
    sourceMap: true

Options (optional):


Type: boolean
Default: false

Generates a source map (nodes should contain positions in loc property). Note, that an object instead of string is returned in that case.

var ast = csstree.parse('.test { color: red }', {
    filename: 'my.css',
    positions: true

var result = csstree.generate(ast, { sourceMap: true });
// { css: '.test{color:red}', map: SourceMapGenerator {} }


Type: function
Default: none

A function that a handlers used by a generator. TBD

You can’t perform that action at this time.