UNPKG

adonisjs-livewire

Version:

A front-end framework for AdonisJS

23 lines (22 loc) 1.11 kB
export default class LivewireTag { tagName = 'livewire'; block = false; seekable = true; compile(parser, buffer, token) { const parsed = parser.utils.transformAst(parser.utils.generateAST(token.properties.jsArg, token.loc, token.filename), token.filename, parser); if (parsed.expressions) { const componentClass = parser.utils.stringify(parsed.expressions[0]); const componentParams = parsed.expressions[1] ? parser.utils.stringify(parsed.expressions[1]) : '[]'; const componentOptions = parsed.expressions[2] ? parser.utils.stringify(parsed.expressions[2]) : '{}'; buffer.outputExpression(`await state.livewire.mount(${componentClass}, ${componentParams}, ${componentOptions})`, token.filename, token.loc.start.line, false); } else { const componentClass = parser.utils.stringify(parsed); buffer.outputExpression(`await state.livewire.mount(${componentClass})`, token.filename, token.loc.start.line, false); } } }