mirror of
https://github.com/bobwen-dev/react-templates
synced 2025-04-12 00:56:39 +02:00
Don't ignore whitespace in html text
This commit is contained in:
parent
dddc3770a4
commit
68b6015bfd
@ -48,7 +48,6 @@ function concatChildren(children) {
|
|||||||
var curlyMap = {'{': 1, '}': -1};
|
var curlyMap = {'{': 1, '}': -1};
|
||||||
|
|
||||||
function convertText(node, context, txt) {
|
function convertText(node, context, txt) {
|
||||||
txt = txt.trim();
|
|
||||||
var res = '';
|
var res = '';
|
||||||
var first = true;
|
var first = true;
|
||||||
while (txt.indexOf('{') !== -1) {
|
while (txt.indexOf('{') !== -1) {
|
||||||
@ -192,13 +191,13 @@ function generateProps(node, context) {
|
|||||||
}));
|
}));
|
||||||
var styleArray = [];
|
var styleArray = [];
|
||||||
_.forEach(styleParts, function (stylePart) {
|
_.forEach(styleParts, function (stylePart) {
|
||||||
styleArray.push(stringUtils.convertToCamelCase(stylePart[0]) + ' : ' + convertText(node, context, stylePart[1]));
|
styleArray.push(stringUtils.convertToCamelCase(stylePart[0]) + ' : ' + convertText(node, context, stylePart[1].trim()));
|
||||||
});
|
});
|
||||||
props[propKey] = '{' + styleArray.join(',') + '}';
|
props[propKey] = '{' + styleArray.join(',') + '}';
|
||||||
} else if (key === classSetProp) {
|
} else if (key === classSetProp) {
|
||||||
props[propKey] = classSetTemplate({classSet: val});
|
props[propKey] = classSetTemplate({classSet: val});
|
||||||
} else if (key.indexOf('rt-') !== 0) {
|
} else if (key.indexOf('rt-') !== 0) {
|
||||||
props[propKey] = convertText(node, context, val);
|
props[propKey] = convertText(node, context, val.trim());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -298,7 +297,7 @@ function convertHtmlToReact(node, context) {
|
|||||||
return (commentTemplate(node));
|
return (commentTemplate(node));
|
||||||
} else if (node.type === 'text') {
|
} else if (node.type === 'text') {
|
||||||
if (node.data.trim()) {
|
if (node.data.trim()) {
|
||||||
return convertText(node, context, node.data.trim());
|
return convertText(node, context, node.data);
|
||||||
}
|
}
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
@ -26,6 +26,6 @@ define([
|
|||||||
height: '100%',
|
height: '100%',
|
||||||
border: '0'
|
border: '0'
|
||||||
}
|
}
|
||||||
}))), React.DOM.div({}, 'editor', !this.props.editorState.previewMode ? React.DOM.div({}, 'left bar') : null));
|
}))), React.DOM.div({}, 'editor\n ', !this.props.editorState.previewMode ? React.DOM.div({}, 'left bar') : null));
|
||||||
};
|
};
|
||||||
});
|
});
|
Loading…
x
Reference in New Issue
Block a user