Skip to main content

A simple module to extract html/script/style from a vuejs '.vue' file (can minimize/es2015 compliant js) ... just py2 or py3, NO nodejs !

Project description

vbuild

"Compile" your VUEJS component (*.vue) to standalone html/js/css ... python only (no need of nodejs). BTW it provides a js-minimizer (es2015 compliant code)

BREAKING NEWS : a future version will be able to make your component (script) in PURE PYTHON ! (my tests are really great ! stay tuned !!)

It's just an utility to extract HTML(template), SCRIPT and STYLE from a VUE/SFC component (*.vue). It's PURE python (py2 & py3 compatible), no nodejs ! It's fully unitested (100% !)

It won't replace webpack/nodejs/vue-cli, it fills the "Sometimes you have to work with the tools you have, not the ones you want." gap.

Available on pypi

import vbuild

c=vbuild.render("mycompo.vue")
#c=vbuild.render("vues/*.vue")
#c=vbuild.render( ["c1.vue","c2.vue"] )
#c=vbuild.render( ["main.vue","vues/*.vue"] )
print( c.html )
print( c.script )
print( c.style )

You can use sass(new syntax only) (using <style lang="scss"></style> or <style lang="sass"></style>) or less (using <style lang="less"></style>) in your styles. But you'll need to install pyscss or lesscpy, depending on your needs.

By the way, the module provide a js-minimizer(transpiler) (to generate ES5 compliant js) (thru on the clojure online service)

js="""async function  mymethod(...a) {
    var f=(...a) => {let b=12}
}
"""
min=vbuild.minimize(js)

Notes:

  • templates are converted to a <script type="text/x-template" id="XXX"></script> (not converted to JS)
  • A Minimal component needs the <template></template> tag only (specs)
  • You can use <style></style> and/or <style scoped></style> (as many as you want)
  • styles are minimized (remove comments and spaces)

Its main purpose is to let you use components (.vue files) in your vuejs app, without a full nodejs stack. It's up to you to create your generator, to extract the things, and create your "index.html" file. It's a 4 lines of python code; example:

import vbuild
buf=readYourTemplate("index.tpl") # should contains a tag "<!-- HERE -->" that would be substituted
buf=buf.replace("<!-- HERE -->",str( vbuild.render( "vues/*.vue" ) ) )
writeYourTemplate("index.html",buf)

If you use sass or less, you can define partial like this:

import vbuild
vbuild.partial="$color: red;"
buf=readYourTemplate("index.tpl") # should contains a tag "<!-- HERE -->" that would be substituted
buf=buf.replace("<!-- HERE -->",str( vbuild.render( "vues/*.vue" ) ) )
writeYourTemplate("index.html",buf)

(a real example of rendering vue/sfc components, using vbuild and the marvelous wuy)

Hope it could help ...

TODO:

  • more utilities
  • and docs !

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

vbuild-0.5.0.tar.gz (5.3 kB view details)

Uploaded Source

Built Distribution

vbuild-0.5.0-py2.py3-none-any.whl (5.5 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file vbuild-0.5.0.tar.gz.

File metadata

  • Download URL: vbuild-0.5.0.tar.gz
  • Upload date:
  • Size: 5.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.1.0 requests-toolbelt/0.8.0 tqdm/4.23.4 CPython/3.6.5

File hashes

Hashes for vbuild-0.5.0.tar.gz
Algorithm Hash digest
SHA256 e9aad012a762f09b6b2cdcefa55ca71d943fac95ab5e2e5767fed587d3125c1c
MD5 855aeb4f0c5c4b12dae31d74d05ec8b9
BLAKE2b-256 d3f139ac7c1bf802145964bc5866514893f7b4e44c8ee1a90a35aa920af997f9

See more details on using hashes here.

File details

Details for the file vbuild-0.5.0-py2.py3-none-any.whl.

File metadata

  • Download URL: vbuild-0.5.0-py2.py3-none-any.whl
  • Upload date:
  • Size: 5.5 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.1.0 requests-toolbelt/0.8.0 tqdm/4.23.4 CPython/3.6.5

File hashes

Hashes for vbuild-0.5.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 348805471de2bb9c4e538f909f1c5711d5f893237cac0de84ffbe0f2a1dccc63
MD5 c82bd9b43ff8c57076fcbb97a6abcb51
BLAKE2b-256 c094ab9097d73acdb641b41f46aee5c7243be0c1a580d6b60a3f84a6d75db9c5

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page