Updated to expose an API that I *hope* integrates with ExpressJS.
This commit is contained in:
parent
047b64a60f
commit
669b9d1ca8
2
Makefile
2
Makefile
|
@ -22,7 +22,7 @@ lib:
|
|||
|
||||
$(cof_objects): $(cof_sources)
|
||||
@mkdir -p $(@D)
|
||||
$(COFFEE) -o $(@D) -c $<
|
||||
$(foreach source, $(cof_sources), $(COFFEE) -o $(@D) -c $(source); )
|
||||
|
||||
$(peg_objects): $(peg_sources)
|
||||
@mkdir -p $(@D)
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
tumble = require('./lexer').parse;
|
||||
parse = require('./parser');
|
||||
fs = require 'fs'
|
||||
|
||||
render = (str, options, callback) ->
|
||||
try
|
||||
callback(null, parse(tumble(str), options))
|
||||
catch err
|
||||
callback(err, null)
|
||||
|
||||
fromFile = (path, options, callback) ->
|
||||
fs.readFile path, 'utf8', (err, str) ->
|
||||
return callback(err) if err
|
||||
render(str, options, callback)
|
||||
|
||||
fromFile.render = render
|
||||
|
||||
exports = fromFile
|
|
@ -0,0 +1,10 @@
|
|||
lexer = require './lexer'
|
||||
parse = require './parser'
|
||||
engine = require './engine'
|
||||
|
||||
module.exports = {
|
||||
tumble: lexer.parse,
|
||||
parse: parse,
|
||||
render: (str, data) -> parse(lexer.parse(str), data)
|
||||
engine: engine
|
||||
}
|
|
@ -6,7 +6,7 @@ util = require 'util'
|
|||
fs = require 'fs'
|
||||
path = require 'path'
|
||||
|
||||
tumble = require('../lib/tumble').parse;
|
||||
tumble = require('../lib/lexer').parse;
|
||||
parse = require('../lib/parser');
|
||||
|
||||
test_data = JSON.parse(fs.readFileSync(path.join(__dirname, 'data.json'), 'utf-8'))
|
||||
|
|
Loading…
Reference in New Issue