vuejs / vueify

Browserify transform for single-file Vue components
MIT License
1.17k stars 153 forks source link

Separate template to many files #223

Open EmilMoe opened 6 years ago

EmilMoe commented 6 years ago

I am having a huge component now at 7-800 lines and I would very much like to split it to different files. My biggest part of the component is the template section and I would therefor like to know if it's possible to include parts from other files? I have seen that you can do a <template src="file.html"></template> but only if it's at the root level.

Is there an option when I want to do it in the middle of my template section?

inca commented 6 years ago

Fwiw I usually split heavy templates into separate components, just pass required stuff there as prop.

Oftentimes this leads to a better separation of concerns (e.g. props, computed and methods are nautrally split between sub-components and almost never shared). However, in rare cases you can also pass this as a prop to child component — this way child will have a direct access to parent.

EmilMoe commented 6 years ago

Thanks, but.. I wish I could, but maybe I just don't understand some logic. It's a component with sub components so everything screws up when I separeate those subs, maybe because the sub has a callback once completed.

I tried a few things out but I didn't succeed and I think reasonable time has run out :-(