add use strict to generated code

This commit is contained in:
ido 2014-11-11 11:27:59 +02:00
parent e4c5d6e613
commit 208c2fc651
6 changed files with 11 additions and 6 deletions

View File

@ -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",

View File

@ -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: {}
};

View File

@ -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([])));
}; };

View File

@ -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;

View File

@ -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([{

View File

@ -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);
} }
} }
}); });