UNPKG

generator-portals-clientside

Version:

Generates a SharePoint clientside project skeleton. Brought to you by Skyline's Portals & Collaboration Team.

32 lines (27 loc) 919 B
/* ======= Usage ========== * To add to a page, add the following script * <%= namespace %>.components.<%= name %>.create(selector); * ======================== */ var create = function(containerSelector) { var component = {}; component.container = document.querySelector(containerSelector); component.message = "Hi my name is '<%= name %>' Component."; component.init = function() { component.render(); // Here is where you'd make an API call to get data then re-render // component.getData() // .then(component.processData) // .then(component.render) }; // Render the main guts of the component right away component.render = function() { var html = `<h1>${component.message}</h1>` if (component.container) { component.container.innerHTML = html; } }; component.init(); return component; }; module.exports = { create: create };