mirror of
https://github.com/bobwen-dev/react-templates
synced 2025-04-12 00:56:39 +02:00
Packed the sample again
This commit is contained in:
parent
68b6015bfd
commit
229f046167
@ -69134,6 +69134,7 @@ var stringUtils = require('./stringUtils');
|
||||
|
||||
var repeatTemplate = _.template('_.map(<%= collection %>,<%= repeatFunction %>.bind(<%= repeatBinds %>))');
|
||||
var ifTemplate = _.template('((<%= condition %>)?(<%= body %>):null)');
|
||||
var propsTemplate = _.template('_.merge({}, <%= generatedProps %>, <%= rtProps %>)');
|
||||
var classSetTemplate = _.template('React.addons.classSet(<%= classSet %>)');
|
||||
var simpleTagTemplate = _.template('<%= name %>(<%= props %><%= children %>)');
|
||||
var tagTemplate = _.template('<%= name %>.apply(this,_.flatten([<%= props %><%= children %>]))');
|
||||
@ -69145,6 +69146,7 @@ var templateProp = 'rt-repeat';
|
||||
var ifProp = 'rt-if';
|
||||
var classSetProp = 'rt-class';
|
||||
var scopeProp = 'rt-scope';
|
||||
var propsProp = 'rt-props';
|
||||
|
||||
var reactSupportedAttributes = ['accept', 'acceptCharset', 'accessKey', 'action', 'allowFullScreen', 'allowTransparency', 'alt', 'async', 'autoComplete', 'autoPlay', 'cellPadding', 'cellSpacing', 'charSet', 'checked', 'classID', 'className', 'cols', 'colSpan', 'content', 'contentEditable', 'contextMenu', 'controls', 'coords', 'crossOrigin', 'data', 'dateTime', 'defer', 'dir', 'disabled', 'download', 'draggable', 'encType', 'form', 'formNoValidate', 'frameBorder', 'height', 'hidden', 'href', 'hrefLang', 'htmlFor', 'httpEquiv', 'icon', 'id', 'label', 'lang', 'list', 'loop', 'manifest', 'max', 'maxLength', 'media', 'mediaGroup', 'method', 'min', 'multiple', 'muted', 'name', 'noValidate', 'open', 'pattern', 'placeholder', 'poster', 'preload', 'radioGroup', 'readOnly', 'rel', 'required', 'role', 'rows', 'rowSpan', 'sandbox', 'scope', 'scrolling', 'seamless', 'selected', 'shape', 'size', 'sizes', 'span', 'spellCheck', 'src', 'srcDoc', 'srcSet', 'start', 'step', 'style', 'tabIndex', 'target', 'title', 'type', 'useMap', 'value', 'width', 'wmode'];
|
||||
var attributesMapping = {'class': 'className', 'rt-class': 'className'};
|
||||
@ -69169,7 +69171,6 @@ function concatChildren(children) {
|
||||
var curlyMap = {'{': 1, '}': -1};
|
||||
|
||||
function convertText(node, context, txt) {
|
||||
txt = txt.trim();
|
||||
var res = '';
|
||||
var first = true;
|
||||
while (txt.indexOf('{') !== -1) {
|
||||
@ -69313,13 +69314,13 @@ function generateProps(node, context) {
|
||||
}));
|
||||
var styleArray = [];
|
||||
_.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(',') + '}';
|
||||
} else if (key === classSetProp) {
|
||||
props[propKey] = classSetTemplate({classSet: val});
|
||||
} else if (key.indexOf('rt-') !== 0) {
|
||||
props[propKey] = convertText(node, context, val);
|
||||
props[propKey] = convertText(node, context, val.trim());
|
||||
}
|
||||
});
|
||||
|
||||
@ -69384,6 +69385,9 @@ function convertHtmlToReact(node, context) {
|
||||
stringUtils.addIfNotThere(context.boundParams, data.item + 'Index');
|
||||
}
|
||||
data.props = generateProps(node, context);
|
||||
if (node.attribs[propsProp]) {
|
||||
data.props = propsTemplate({generatedProps: data.props, rtProps: node.attribs[propsProp]});
|
||||
}
|
||||
if (node.attribs[ifProp]) {
|
||||
data.condition = node.attribs[ifProp].trim();
|
||||
}
|
||||
@ -69416,7 +69420,7 @@ function convertHtmlToReact(node, context) {
|
||||
return (commentTemplate(node));
|
||||
} else if (node.type === 'text') {
|
||||
if (node.data.trim()) {
|
||||
return convertText(node, context, node.data.trim());
|
||||
return convertText(node, context, node.data);
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user