-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use Rollup for packaging dist files, update package.json scripts and …
…documentation
- Loading branch information
1 parent
9e8bf0d
commit 22cb5a8
Showing
14 changed files
with
846 additions
and
377 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,2 @@ | ||
dist/* | ||
scripts/* | ||
spec/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/*! | ||
* TemplateTemplate v0.3.0 | ||
* | ||
* A very small JavaScript <template> manipulation library. | ||
* | ||
* Source code available at: https://github.com/jgarber623/TemplateTemplate | ||
* | ||
* (c) 2018-present Jason Garber (https://sixtwothree.org) | ||
* | ||
* TemplateTemplate may be freely distributed under the MIT license. | ||
*/ | ||
|
||
function TemplateTemplate(template, insertions) { | ||
template = template instanceof HTMLElement ? template : document.querySelector(template); | ||
insertions = insertions || {}; | ||
if (template === null || !(template instanceof HTMLTemplateElement)) { | ||
throw new TypeError(template + " is not an HTMLTemplateElement"); | ||
} | ||
if (typeof insertions !== "object") { | ||
throw new TypeError(insertions + " is not an Object"); | ||
} | ||
var importedNode = document.importNode(template.content, true); | ||
Object.entries(insertions).forEach(function(insertionArray) { | ||
var currentNode = importedNode.querySelector(insertionArray[0]), insertionValue = insertionArray[1]; | ||
if (insertionValue instanceof Array) { | ||
Object.entries(insertionValue[1]).forEach(function(attributesArray) { | ||
currentNode.setAttribute(attributesArray[0], attributesArray[1]); | ||
}); | ||
insertionValue = insertionValue[0]; | ||
} | ||
if (insertionValue instanceof DocumentFragment || insertionValue instanceof HTMLElement) { | ||
currentNode.appendChild(insertionValue); | ||
} else { | ||
currentNode.textContent = insertionValue; | ||
} | ||
}); | ||
return importedNode; | ||
} | ||
|
||
export default TemplateTemplate; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.