Last active
August 29, 2015 14:17
-
-
Save coodoo/dbbf7d263e972a59e64e to your computer and use it in GitHub Desktop.
Convert css file to js object and clean up the key a bit to stripe '.' so that it's compatible with react-native
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
// var convert = require('css-to-radium'); | |
// var fs = require('fs'); | |
// var path = require('path'); | |
// var css = fs.readFileSync( path.resolve('./', 'app.css'), 'utf8'); | |
// var result = convert(css); | |
// console.log( '\nresult: \n', require('util').inspect( result, false, 2, true) ); | |
// 模擬 css 轉換後的 js 物件,要將 .foo 轉成 foo | |
var o = { | |
'.foo': 'barr', | |
'.coo': 'dooo', | |
'aa': 'bb' | |
} | |
var k, v, r={}; | |
for( k in o ){ | |
v = o[k]; | |
k = k.indexOf('.')==0 ? k.replace('.', '') : k; | |
r[k] = v; | |
} | |
console.log( '\n轉完 \n', require('util').inspect( r, false, 0, true) ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment