Skip to content
This repository has been archived by the owner on Mar 20, 2021. It is now read-only.

Commit

Permalink
Avoid intermediate object in tag util
Browse files Browse the repository at this point in the history
  • Loading branch information
kpdecker committed Oct 14, 2014
1 parent 7d792fc commit 3c5aa0a
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -338,16 +338,15 @@ Thorax.Util = {
return input;
},
tag: function(attributes, content, scope) {
var htmlAttributes = _.omit(attributes, 'tagName'),
tag = attributes.tagName || 'div',
var tag = attributes.tagName || 'div',
noClose = isVoidTag(tag);

if (noClose && content) {
throw new Error(createErrorMessage('void-tag-content'));
}

var openingTag = '<' + tag + ' ' + _.map(htmlAttributes, function(value, key) {
if (_.isUndefined(value) || key === 'expand-tokens') {
var openingTag = '<' + tag + ' ' + _.map(attributes, function(value, key) {
if (value == null || key === 'expand-tokens' || key === 'tagName') {
return '';
}
var formattedValue = value;
Expand All @@ -360,7 +359,7 @@ Thorax.Util = {
if (noClose) {
return openingTag;
} else {
return openingTag + (_.isUndefined(content) ? '' : content) + '</' + tag + '>';
return openingTag + (content == null ? '' : content) + '</' + tag + '>';
}
}
};

0 comments on commit 3c5aa0a

Please sign in to comment.