Skip to content

Commit

Permalink
added logic for 1 tag elements
Browse files Browse the repository at this point in the history
  • Loading branch information
avigoldman committed Oct 15, 2017
1 parent 216cffa commit 8bbd04a
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
5 changes: 5 additions & 0 deletions packages/heml-render/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions packages/heml-render/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"author": "SparkPost <[email protected]> (https://sparkpost.com)",
"license": "MIT",
"dependencies": {
"html-tags": "^2.0.0",
"is-promise": "^2.1.0",
"lodash": "^4.17.4",
"stringify-attributes": "^1.0.0"
Expand Down
5 changes: 5 additions & 0 deletions packages/heml-render/src/renderElement.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import stringifyAttributes from 'stringify-attributes'
import isPromise from 'is-promise'
import { isString, isArray, defaults, mapValues, castArray } from 'lodash'
import selfClosingHtmlTags from 'html-tags/void'

export default function (name, attrs, contents) {
if (!isString(name)) {
Expand Down Expand Up @@ -39,5 +40,9 @@ export default function (name, attrs, contents) {
}

/** if we have a regular ol element go ahead and convert it to a string */
if (selfClosingHtmlTags.includes(name)) {
return `<${name}${attrs ? stringifyAttributes(attrs) : ''} />`
}

return `<${name}${attrs ? stringifyAttributes(attrs) : ''}>${contents || '&zwnj;'}</${name}>`
}

0 comments on commit 8bbd04a

Please sign in to comment.