views-morph
Version:
Views language morpher
19 lines (15 loc) • 475 B
JavaScript
import { getProp, isCode } from '../utils.js'
import safe from '../react/safe.js'
export const enter = (node, parent, state) => {
if (node.teleport) {
let to = getProp(node, 'teleportTo').value
if (to.startsWith('/') || to === '..') {
to = safe(to)
} else {
to = isCode(to) ? `\${${to}}` : to
to = `{\`\${props.match.url === '/' ? '' : props.match.url}/${to}\`}`
state.withRouter = true
}
state.render.push(` to=${to}`)
}
}