alexjoverm / v-runtime-template

Vue component for compiling templates on the fly using a v-html like API
MIT License
605 stars 72 forks source link

Is it possible to use this component without ES Modules? #37

Closed jess closed 5 years ago

r0the commented 5 years ago

Yes, it is. I use it like:

<script src="vue.min.js"></script>
<script src="v-runtime-template.min.js"></script>
<script>
  Vue.component('v-runtime-template', VRuntimeTemplate)
</script>
jess commented 5 years ago

@r0the ah, thanks so much!! I was trying with Vue.use(VRuntimeTemplate)

Would it be helpful if I submitted a submitted a PR to update the docs to include this??

jess commented 5 years ago

I'm trying to get your example runinning in a fiddle. But, I'm getting an error message:

vue.js:634 [Vue warn]: Error in render: "TypeError: Cannot convert undefined or null to object"

found in

---> <VRuntimeTemplate>
       <Root>

https://jsfiddle.net/bjessbrown/8wb90q4n/36/

r0the commented 5 years ago

The first argument of Vue.component() is the HTML tag name. So for your example to work. you should write:

<VRuntimeTemplate>
</VRuntimeTemplate>
<script src="vue.min.js"></script>
<script src="v-runtime-template.min.js"></script>
<script>
  Vue.component('VRuntimeTemplate', VRuntimeTemplate)
</script>

or alternatively

<v-runtime-template>
</v-runtime-template>
<script src="vue.min.js"></script>
<script src="v-runtime-template.min.js"></script>
<script>
  Vue.component('v-runtime-template', VRuntimeTemplate)
</script>

I use the second variant as this is the way it's used in the Vue documentation.

jess commented 5 years ago

@r0the would you mind looking at this sample and tell me if something is incorrect. I cannot get v-runtime-template to work without ES modules.

https://jsfiddle.net/bjessbrown/8wb90q4n/36/

I also pulled down code and debugged the errors and was able to get it to work by changing some of the code (not as a solution, but just to get this example to work). You can see my changes here 9dfe5664f4fa673068f0c45d99dbf110ad25dcfa. Maybe they will help??