refactor helpers.

This commit is contained in:
Christopher Jeffrey 2015-05-01 00:33:34 -07:00
parent 3e8083d5a1
commit f5f2b71562
1 changed files with 28 additions and 28 deletions

View File

@ -9055,34 +9055,6 @@ blend._cache = {};
var helpers = {};
helpers.generateTags = function(style, text) {
var open = ''
, close = '';
Object.keys(style || {}).forEach(function(key) {
var val = style[key];
if (typeof val === 'string') {
val = val.replace(/^light(?!-)/, 'light-');
open = '{' + val + '-' + key + '}' + open;
close += '{/' + val + '-' + key + '}';
} else {
if (val === true) {
open = '{' + key + '}' + open;
close += '{/' + key + '}';
}
}
});
if (text != null) {
return open + text + close;
}
return {
open: open,
close: close
};
};
helpers.merge = function(a, b) {
Object.keys(b).forEach(function(key) {
a[key] = b[key];
@ -9163,6 +9135,34 @@ helpers.parseTags = function(text) {
{ parseTags: true, screen: Screen.global }, text);
};
helpers.generateTags = function(style, text) {
var open = ''
, close = '';
Object.keys(style || {}).forEach(function(key) {
var val = style[key];
if (typeof val === 'string') {
val = val.replace(/^light(?!-)/, 'light-');
open = '{' + val + '-' + key + '}' + open;
close += '{/' + val + '-' + key + '}';
} else {
if (val === true) {
open = '{' + key + '}' + open;
close += '{/' + key + '}';
}
}
});
if (text != null) {
return open + text + close;
}
return {
open: open,
close: close
};
};
helpers.attrToBinary = function(style, element) {
return Element.prototype.sattr.call(element || {}, style);
};