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",
"main": "./src/reactTemplates.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
"test": "node test/src/test.js"
},
"repository": {
"type": "git",

View File

@ -108,7 +108,6 @@ function generateProps(node, context) {
str = str.trim();
if (!str || str.indexOf(':') === -1) {
return null;
}
var res = str.split(':');
res[0] = res[0].trim();
@ -253,5 +252,8 @@ function convertFile(source, target) {
fs.writeFileSync(target, js);
}
module.exports.convertTemplateToReact = convertTemplateToReact;
module.exports.convertFile = convertFile;
module.exports = {
convertTemplateToReact: convertTemplateToReact,
convertFile: convertFile,
_test: {}
};

View File

@ -2,6 +2,7 @@ define([
'react',
'lodash'
], function (React, _) {
'use strict';
return function () {
return React.DOM.div.apply(this, _.flatten([{}].concat([])));
};

View File

@ -2,6 +2,7 @@ define([
'react',
'lodash'
], function (React, _) {
'use strict';
function generated1(items, itemsIndex, evt) {
this.happend(evt);
return false;

View File

@ -2,6 +2,7 @@ define([
'react',
'lodash'
], function (React, _) {
'use strict';
return function () {
return React.DOM.div.apply(this, _.flatten([{}].concat([
React.DOM.div.apply(this, _.flatten([{

View File

@ -7,7 +7,7 @@ var path = require('path');
var dataPath = path.resolve(__dirname, '..', 'data');
test('timing test', function (t) {
test('conversion test', function (t) {
var files = ['div.rt', 'test.rt', 'repeat.rt'];
t.plan(files.length);
@ -21,7 +21,7 @@ test('timing test', function (t) {
var actual = reactTemplates.convertTemplateToReact(html);
t.equal(actual, expected);
if (actual !== expected) {
fs.writeFileSync(filename + ".actual.js", actual);
fs.writeFileSync(filename + '.actual.js', actual);
}
}
});