Giter Club home page Giter Club logo

python-module's Introduction

@nuxtjs/python

npm (scoped with tag) npm CircleCI Codecov Dependencies js-standard-style

Write Nuxt.js Apps in Python

๐Ÿ“– Release Notes

Features

  • Write Nuxt 2 applications using Python!
  • Currently only supports custom Javascripthon but in the future other compilers will also be expected to work.

Try the example

  1. Clone this repository and change directory into it
  2. Install dependencies:
    npm install                         # or use yarn
    
    pip install -r requirements.txt
    
  3. Run example: npm run dev

Setup in your own project

  • Add @nuxtjs/python dependency using yarn or npm to your project
  • Add @nuxtjs/python to modules section of nuxt.config.js
    {
      modules: [
        '@nuxtjs/python'
      ],
      python: {
        compiler: 'pj'   // default
      }
    }
  • In Vue files, Mark your script tags like this: <script lang="py">.
  • You may pass options to py-loader (currently it supports compiler parameter)

Choice of Python to Javascript compiler

Compiler default and recommended is Javascripthon but it is possible to use other compilers (see below).

  • Install the Javascripthon Python transpiler. For now you'll need the master branch e.g:

    pip install -e git+https://gitlab.com/metapensiero/metapensiero.pj#egg=javascripthon
    
  • Note that Javascripthon requires that you have Python 3.5 (or better).

  • Javascripthon supports converting Python import statements to ES6 imports as used in Nuxt. Please note syntax conversions.

  • You can pass a compiler option to py-loader by using module options or in a python section in your nuxt.config.js file.

  • Transcrypt has its own module system so in order to use it, you can use the CommonJS module standard (require to import and module.exports) and it should work. See the py-loader Vuejs example.

Usage

Using .vue files

TIP If you use Vim you can get syntax highlighting for HTML, CSS and Python by installing vim-vue plugin and applying this patch.

hello.vue:

<template>
  <div>
      Nuxt {{ best_lang }}
  </div>
</template>

<script lang="py">
class Component:
  def __init__(self):
      self['data'] = lambda: { 'best_lang': 'Python' }

__default__ = Component()
</script>

Using .py files for other nuxt files

store/index.py

from vuex import Store

def increment(state):
    state.counter = state.counter + 1

def createStore():
    return Store(
      state={'counter': 0},
      mutations={'increment': increment}
    )

__default__ = createStore

pages/counter.vue

<template>
  <h2>{{ $store.state.counter }}</h2>
  <button @click="$store.commit('increment')">+1</button>
</template>

๐Ÿ‘‰ For a working example, see here.

Development

  • Clone this repository
  • Install dependencies using yarn install or npm install
  • Start development server using npm run dev

License

MIT License

Copyright (c) Sebastian Silva [email protected]

This module was started from the module-template by Pooya Parsa and relies heavily on python-webpack-loader by Martim Nascimento and Javascripthon by Alberto Berti.

python-module's People

Contributors

atinux avatar harlan-zw avatar icarito avatar renovate-bot avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

python-module's Issues

Some error occurred on Pj compiler execution

Interesting module. I really would like to use it, but does it still work?

After folowing the instructions I get:
ERROR Some error occurred on Pj compiler execution. Have you installed Pj? If not, please run pip install javascripthon (requires Python 3.x)
While nuxt has been properly configured
image

pj runs ok from console, but fails on starting the nuxt server with latest version 2.15.8.

Tried:

Nuxt 3 Support

Hey ๐Ÿ‘‹ It looks like this module hasn't been updated for Nuxt 3. In an effort to improve the developer experience of modules, I've updated the module to clarify that it only supports Nuxt 2.

If Nuxt 3 support is added it will be moved to the https://github.com/nuxt-modules organisation.

cc: @icarito Please let me know if you need a hand with anything otherwise no action is needed.

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Repository problems

These problems occurred while renovating this repository. View logs.

  • WARN: Using npm packages for Renovate presets is now deprecated. Please migrate to repository-based presets instead.

Edited/Blocked

These updates have been manually edited so Renovate will no longer make changes. To discard all commits and start over, click on a checkbox.

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Detected dependencies

circleci
.circleci/config.yml
  • circleci/python 3.5-node
npm
example/package.json
package.json
  • @nuxtjs/pwa ^2.0.5
  • eslint ^4.17.0
  • eslint-plugin-jest ^21.8.0
  • eslint-plugin-node ^6.0.0
  • jest ^22.2.2

  • Check this box to trigger a request for Renovate to run again on this repository

CI Tests failing with both python 2 and python 3

Hey @icarito. I've tried make CI tests passing. But build fails with this error:

ERROR in ./node_modules/py-loader?compiler=pj!./node_modules/vue-loader/lib/selector.js?type=script&index=0!./test/fixture/pages/index.vue
Module parse failed: Unexpected token (1:16)

https://circleci.com/gh/nuxt-community/python-module/4

Would you please take a look at it? (Since you are a python geek ๐Ÿค“ )

This question is available on Nuxt.js community (#c1)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.