add use strict to generated code
This commit is contained in:
parent
e4c5d6e613
commit
208c2fc651
|
@ -4,7 +4,7 @@
|
||||||
"description": "Light weight templates for react -> write html get valid react code",
|
"description": "Light weight templates for react -> write html get valid react code",
|
||||||
"main": "./src/reactTemplates.js",
|
"main": "./src/reactTemplates.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "echo \"Error: no test specified\" && exit 1"
|
"test": "node test/src/test.js"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
|
|
|
@ -108,7 +108,6 @@ function generateProps(node, context) {
|
||||||
str = str.trim();
|
str = str.trim();
|
||||||
if (!str || str.indexOf(':') === -1) {
|
if (!str || str.indexOf(':') === -1) {
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
}
|
}
|
||||||
var res = str.split(':');
|
var res = str.split(':');
|
||||||
res[0] = res[0].trim();
|
res[0] = res[0].trim();
|
||||||
|
@ -253,5 +252,8 @@ function convertFile(source, target) {
|
||||||
fs.writeFileSync(target, js);
|
fs.writeFileSync(target, js);
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports.convertTemplateToReact = convertTemplateToReact;
|
module.exports = {
|
||||||
module.exports.convertFile = convertFile;
|
convertTemplateToReact: convertTemplateToReact,
|
||||||
|
convertFile: convertFile,
|
||||||
|
_test: {}
|
||||||
|
};
|
|
@ -2,6 +2,7 @@ define([
|
||||||
'react',
|
'react',
|
||||||
'lodash'
|
'lodash'
|
||||||
], function (React, _) {
|
], function (React, _) {
|
||||||
|
'use strict';
|
||||||
return function () {
|
return function () {
|
||||||
return React.DOM.div.apply(this, _.flatten([{}].concat([])));
|
return React.DOM.div.apply(this, _.flatten([{}].concat([])));
|
||||||
};
|
};
|
||||||
|
|
|
@ -2,6 +2,7 @@ define([
|
||||||
'react',
|
'react',
|
||||||
'lodash'
|
'lodash'
|
||||||
], function (React, _) {
|
], function (React, _) {
|
||||||
|
'use strict';
|
||||||
function generated1(items, itemsIndex, evt) {
|
function generated1(items, itemsIndex, evt) {
|
||||||
this.happend(evt);
|
this.happend(evt);
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -2,6 +2,7 @@ define([
|
||||||
'react',
|
'react',
|
||||||
'lodash'
|
'lodash'
|
||||||
], function (React, _) {
|
], function (React, _) {
|
||||||
|
'use strict';
|
||||||
return function () {
|
return function () {
|
||||||
return React.DOM.div.apply(this, _.flatten([{}].concat([
|
return React.DOM.div.apply(this, _.flatten([{}].concat([
|
||||||
React.DOM.div.apply(this, _.flatten([{
|
React.DOM.div.apply(this, _.flatten([{
|
||||||
|
|
|
@ -7,7 +7,7 @@ var path = require('path');
|
||||||
|
|
||||||
var dataPath = path.resolve(__dirname, '..', 'data');
|
var dataPath = path.resolve(__dirname, '..', 'data');
|
||||||
|
|
||||||
test('timing test', function (t) {
|
test('conversion test', function (t) {
|
||||||
var files = ['div.rt', 'test.rt', 'repeat.rt'];
|
var files = ['div.rt', 'test.rt', 'repeat.rt'];
|
||||||
t.plan(files.length);
|
t.plan(files.length);
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@ test('timing test', function (t) {
|
||||||
var actual = reactTemplates.convertTemplateToReact(html);
|
var actual = reactTemplates.convertTemplateToReact(html);
|
||||||
t.equal(actual, expected);
|
t.equal(actual, expected);
|
||||||
if (actual !== expected) {
|
if (actual !== expected) {
|
||||||
fs.writeFileSync(filename + ".actual.js", actual);
|
fs.writeFileSync(filename + '.actual.js', actual);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue