1
0
Fork 0
mirror of synced 2024-09-18 18:28:33 +12:00
budibase/packages/builder/src/builderStore/buildCodeForScreens.js

34 lines
687 B
JavaScript
Raw Normal View History

const buildCodeForSingleScreen = screen => {
let code = ""
const walkProps = props => {
if (props._code && props._code.trim().length > 0) {
code += buildComponentCode(props)
}
if (!props._children) return
for (let child of props._children) {
walkProps(child)
}
}
walkProps(screen.props)
return code
}
export const buildCodeForScreens = screens => {
let allfunctions = ""
for (let screen of screens) {
allfunctions += buildCodeForSingleScreen(screen)
}
return `({ ${allfunctions} });`
}
const buildComponentCode = componentProps =>
2020-02-26 05:01:23 +13:00
`"${componentProps._id}" : (render, context, state, route) => {
${componentProps._code}
},
`