antonmedv / monkberry

Monkberry is a JavaScript library for building web user interfaces
https://monkberry.js.org
MIT License
1.49k stars 78 forks source link

Where to put directive with browserify setup? #44

Closed Abdillah closed 7 years ago

Abdillah commented 7 years ago

Hi @antonmedv , I love this library as it does what it should!

But, I have a question. I have a setup where monkberry used with browserify. It compiles all monk files and include it elsewhere. The think is, I have no way (in my knowledge) to specify directive to use.

Can I put what directives to use directly in my *.monk file?

{% import directives from 'monkberry-directives' %}

<div :show="{{ variable }}">...</div>

Or in my class which extend the generated Template class?

import directives from 'monkberry-directives';

class View extends Template {
    constructor() {
         super();
         this.directives = directives;
    }
}

Which both happen to do nothing..

Am I make mistake?

antonmedv commented 7 years ago
import Monkberry from 'monkberry';
import Template from 'template.monk';
import directives from 'monkberry-directives';

const view = Monkberry.render(Template, document.body, {directives});

More at https://monkberry.js.org/docs/directives

Abdillah commented 7 years ago

I'm sorry, yeah, that's the case! Thank you..

Just curious, is there currently other way to include directives from .monk or class directly?

antonmedv commented 7 years ago

I think no.

Abdillah commented 7 years ago

Okay, thaks