2016년 3월 6일 일요일

htmltojsx all files in directory

publishing html file to jsx is hard working.

webversion https://facebook.github.io/react/html-jsx.html

1. install glob and htmltojsx
#npm install htmltojsx -g
#npm install glob
2. 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

댓글 없음:

댓글 쓰기

eclipse rcp dialog resize

  Dialog 안에 메소드를 만든다. private void autoResize(){     getShell().layout( true, true);     final Point newSize = getShell().computeSize...