publishing html file to jsx is hard working.
webversion https://facebook.github.io/react/html-jsx.html
1. install glob and htmltojsx
webversion https://facebook.github.io/react/html-jsx.html
1. install glob and htmltojsx
#npm install htmltojsx -g #npm install glob2. convert.js
var glob = require("glob")
var sys = require('sys')
var exec = require('child_process').exec;
function puts(error, stdout, stderr) { sys.puts(stdout) }
// options is optional
glob("html/pub/pages/*.html", {}, function (er, files) {
// files is an array of filenames.
// If the `nonull` option is set, and nothing
// was found, then files is ["**/*.js"]
// er is an error object or null.
//console.log(files);
var src = '/Users/hongsangbeom/Documents/moneytag/html/pub/pages';
var dst = '/Users/hongsangbeom/Documents/moneytag/html/dev/tmp';
for(var index in files){
var fnameArr = files[index].split('/');
var fileName = fnameArr[fnameArr.length-1];
var nArr = fileName.split('.');
var srcFile = src +'/'+ fileName;
var dstFile = dst +'/'+ nArr[0]+'.js';
var cmd = 'htmltojsx -c '+nArr[0]+' '+srcFile+' > ' + dstFile;
console.log(cmd);
exec(cmd, puts);
}
})
3. run
#node convert.js
댓글
댓글 쓰기