Skip to content

Commit

Permalink
GH-48 Add getWidgetByName method
Browse files Browse the repository at this point in the history
  • Loading branch information
david-polak committed Aug 18, 2019
1 parent fefe96f commit c686dec
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/runtime/builders/api/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,25 @@ function getModelByName(name) {
return found
}

function getWidgetByName(name) {
let found = null
Object.entries(widgets).forEach(([, widget]) => {
if (widget.name === name) {
if (found !== null) {
console.warn(`Multiple widgets named ${name}, returning last`)
}
found = widget
}
})
return found
}


export default () => {
const script = `
${generateTemplate(getModelByID)}
${generateTemplate(getModelByName)}
${generateTemplate(getWidgetByName)}
${generateTemplate(getAnimateAnimByID)}
${generateTemplate(getAnimateTextByID)}
${generateTemplate(getButtonByID)}
Expand Down

0 comments on commit c686dec

Please sign in to comment.