Skip to content

Add javascripthon #8

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Jan 21, 2018
Merged

Add javascripthon #8

merged 6 commits into from
Jan 21, 2018

Conversation

icarito
Copy link
Contributor

@icarito icarito commented Jan 18, 2018

:-)

@icarito
Copy link
Contributor Author

icarito commented Jan 20, 2018

This is giving me some issues as it seems I need to parse stderr too, or it could freeze.
Working on it.

@icarito
Copy link
Contributor Author

icarito commented Jan 21, 2018

This seems to work ok.

@icarito
Copy link
Contributor Author

icarito commented Jan 21, 2018

I'd still miss a good error message when pj is not installed...

@icarito
Copy link
Contributor Author

icarito commented Jan 21, 2018

Hi, now I'm proud ;-)
I'm using this with vue-loader to make python vue.js web components :-D

@martim00
Copy link
Owner

Wow, great job! I didn't know about javascripthon. Very impressive framework. I'll test asap.
Also, let me ask. How do you manage to get vue-loader work with this? Do you mind in putting an example in the /example folder?

@martim00 martim00 merged commit e310d56 into martim00:master Jan 21, 2018
@icarito
Copy link
Contributor Author

icarito commented Jan 21, 2018

Excited to be of help. Obrigado for the project.
I am able to make Vue-components like below. The syntax vue wants is not great, looking for a better style:

<script lang="py?compiler=pj">

class Component:
    def __init__(self):
        self['data'] = lambda: { 'test': 2 }
        self['components'] = { 
                      'AppLogo':require('~/components/AppLogo.vue')['default'] }
        self['computed'] = { 'data': lambda: 2 }


module.exports = Component()

</script>

I am using the nuxt.js framework.

@icarito
Copy link
Contributor Author

icarito commented Jan 21, 2018

Here's another attempt with nicer syntax thanks to vue-class-component:

<script lang="py?compiler=pj">

Vue = require('vue')['default']
component = require('vue-class-component')['default']

@component
class MyIndex(Vue):

    def __init__(self):
        super().__init__()
        self['components'] = { 'AppLogo':require('~/components/AppLogo.vue')['default'] }
        self['data'] = self.data

    def data(self):
        return { 'test': 2 }

    @property
    def my_value(self):
        return 3

module.exports = MyIndex()

</script>

@martim00
Copy link
Owner

Cool, very interesting approach! I will experiment with this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants