Created
January 11, 2022 15:31
-
-
Save ItsOnlyBinary/a8f1dab7e27c8515ea332cb1cf2aef99 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<template id="test-template"> | |
<div> | |
<span>test-template</span> | |
<span v-html="content" /> | |
</div> | |
</template> | |
<script> | |
kiwi.plugin('test-body-template', function (kiwi, log) { | |
const testTemplate = { | |
template: '#test-template', | |
data() { | |
return { | |
content: '', | |
show: true, | |
}; | |
}, | |
mounted() { | |
console.log('test-template mounted'); | |
}, | |
}; | |
const testTemplateComponent = kiwi.Vue.extend(testTemplate); | |
kiwi.state.$on('message.poststyle', function (event) { | |
if (!event.message || event.message.type !== 'privmsg') { | |
return; | |
} | |
const content = event.message.html; | |
if (!content) { | |
console.log('no content'); | |
return; | |
} | |
console.log('adding template', content, event); | |
event.message.bodyTemplate = new testTemplateComponent({ | |
data: { | |
content: content, | |
}, | |
}); | |
event.message.bodyTemplate.$mount(); | |
event.message.embed.payload = null; | |
event.message.html = ''; | |
}); | |
}); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment