Created
March 11, 2015 12:46
-
-
Save taijiweb/8a4441e1f440dc58e015 to your computer and use it in GitHub Desktop.
a coffee file to convert template to js by using peasy.coffee
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
es = require('event-stream') | |
gutil = require('gulp-util') | |
# compile transform function from templates by using modules/transform/transformparser | |
# template is in /modules/transform/textualizer/someTemplateTogenerateJavascript | |
generateFromTemplateFile = (file) -> | |
{TemplateParser, FieldTemplateListParser} = require './src/modules/transform/transformparser' | |
filepath = file.history[0] | |
#console.log JSON.stringify filepath | |
filename = filepath.slice(filepath.lastIndexOf('\\')+1, filepath.length-4) | |
#console.log filename | |
#console.log JSON.stringify file.contents | |
moduleHead = """exports.makeActions = function(t){ return """ | |
parser = new FieldTemplateListParser | |
dict = parser.parse(file.contents.toString('utf8')) | |
moduleTail = """;}; """ | |
#console.log dict | |
moduleHead+dict+moduleTail | |
jsTemplatePlugin = (data) -> | |
es.map (file, cb) -> | |
file.contents = new Buffer generateFromTemplateFile(file) | |
cb(null, file) | |
module.exports = jsTemplatePlugin |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment