vue.py icon indicating copy to clipboard operation
vue.py copied to clipboard

Support .vue single file components

Open agritheory opened this issue 6 years ago • 4 comments

The spec for reference.

import Vue from 'vue'
import Router from 'vue-router'
import Hello from '@/components/Hello'

I think an implementation of this exact API would involve monkey patching the import statement to load .vue files. That seems like maybe not the best idea, and an sfg loader utility/class would be required underneath regardless. That could have a more explicit API.

agritheory avatar May 22 '19 12:05 agritheory

what is your use case?

for know the concept is to have a pure python project and do not mix .py and .js/.vue files.

you can have a look at MQTT Dashboard to see how to include an external javascript vue library. see this files app.py and vuepy.yml

stefanhoelzl avatar Jun 26 '19 21:06 stefanhoelzl

I want to write python between the <script> tags in a .vue file. Writing HTML and CSS as docstrings is not as good.

agritheory avatar Jul 04 '19 14:07 agritheory

I agree writing HTML and CSS in python strings is not very comfortable.

But on the other hand in a .vue file you will miss a lot of handy things for your python code (auto-completion, syntax highlighting, refactoring support, ...)

Since I am depending on brython I have to check if it is possible to hook into the import machinery somehow. Another solution similar to vue.js with the vue-loader would be to pre-process the .vue files in the deployment step.

stefanhoelzl avatar Jul 04 '19 17:07 stefanhoelzl

I added some missing documentation how to specify external templates in vuepy.yml.

These allow you to write your html templates in a separate .html-file. In addition with specifying your .css-files also in vuepy.yml you do not need to write any html or css in python strings.

It is still in separate files and not in one single file, but it may be a workaround for the missing .vue file support for now.

stefanhoelzl avatar Aug 14 '19 10:08 stefanhoelzl