Skip to content

Commit

Permalink
feat: add temaplate param
Browse files Browse the repository at this point in the history
  • Loading branch information
dylandepass committed Jan 30, 2023
1 parent 2884e49 commit 237f45a
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/template.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,24 @@
* @returns A fully decorated element for rendering in storybook
*/
function prepare(loadPage: any, args: any, parameters: any, main: any, content: HTMLElement | Element, decorate: any) {
const { selector, index } = parameters;
const { selector, index, template } = parameters;
const { sectionClasses, blockClasses } = args;
const section = document.createElement('div');

const node = content.querySelectorAll(selector).item(index) || content.querySelector(selector);

if(!decorate) {
return;
}

main.appendChild(section);

section.innerHTML = parameters.root ? node.parentNode.innerHTML : node.outerHTML;

if(template) {
decorate(parameters.autoBlock ? main.querySelector('.block') : section.querySelector(selector));
}

loadPage();

if (sectionClasses) {
Expand All @@ -51,7 +59,7 @@ function prepare(loadPage: any, args: any, parameters: any, main: any, content:
});
}

if(decorate) {
if(decorate && !template) {
decorate(parameters.autoBlock ? main.querySelector('.block') : section.querySelector(selector));
}

Expand Down

0 comments on commit 237f45a

Please sign in to comment.