I want do something like this:
mixin table_row(event)
tr
td=event.name
td=event.type
td=event.time
td=event.venue
td
+dropdown(event.id)
script.
const setEvents = (events) => {
let tbody = document.getElementById('events-tbody')
const compile = pug.compile(
`each event in events` +'\n'+
` tr` +'\n'+
` +table_row(event)`
)
tbody.innerHTML = compile({events})
}
On a button click, I am calling an API that fetches events. I want to display these events in a table using table_row mixin that I have already defined in the .pug file.
Right now this code gives an error that table_row is not defined. Is there a way for me to pass this mixin in the pug.compile() function?
Reference: https://pugjs.org/api/reference.html#pugcompilesource-options
from How to use a mixin in pug.compile()
No comments:
Post a Comment