Skip to content

Instantly share code, notes, and snippets.

@ItsOnlyBinary
Created December 9, 2022 15:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ItsOnlyBinary/582e6f2129623900a298fc6e2d6c37ad to your computer and use it in GitHub Desktop.
Save ItsOnlyBinary/582e6f2129623900a298fc6e2d6c37ad to your computer and use it in GitHub Desktop.
<template id="test-template">
<div>
<span>test-template</span>
<span>{{content}}</span>
</div>
</template>
<script>
kiwi.plugin('test-body-template', function (kiwi, log) {
const testTemplate = {
template: '#test-template',
props: ['content', 'buffer', 'message'],
data() {
return {
show: true,
};
},
mounted() {
console.log('test-template mounted', this);
},
};
const testTemplateComponent = kiwi.Vue.extend(testTemplate);
kiwi.state.$on('message.blocks', function (event, blocks) {
console.log('message.blocks', JSON.stringify(event), JSON.stringify(blocks));
});
kiwi.state.$on('message.poststyle', function (event) {
if (!event.message || event.message.type !== 'privmsg') {
return;
}
const content = event.message.message;
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.bodyTemplate = testTemplateComponent;
event.message.bodyTemplateProps = { content: content};
event.message.embed = { type: 'url', payload: null };
event.message.html = '';
});
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment