Skip to content
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

Question about nested partial module loading #80

Open
hsnoil opened this issue Jan 21, 2024 · 6 comments
Open

Question about nested partial module loading #80

hsnoil opened this issue Jan 21, 2024 · 6 comments

Comments

@hsnoil
Copy link

hsnoil commented Jan 21, 2024

Currently, to load up partials you need to do:

import { register } from "./dist/module/mikado.js"
import tpl_header from "./tpl/header.es6.js";

register(tpl_header);
<main>
<section include="header"></section>
</main>

Is there any reason why the template compiler can't have an option to auto import and register all includes that show up in the template? Otherwise you have to manually import all nested partials. To be clear I mean nested template files, not tags.

@ts-thomas
Copy link
Collaborator

Just the ES5 version do automatically register named templates. A module can't, because the template module otherwise needs to import Mikado from a irregular file path.

@ts-thomas
Copy link
Collaborator

If you came up with an idea, let me know :)

@hsnoil
Copy link
Author

hsnoil commented Jan 22, 2024

Though when you bundle it, doesn't it resolve the path to Mikado?

@ts-thomas
Copy link
Collaborator

A template function basically looks like:

export default {
    name: "app",
    tpl: {},
    fn: []
}

We can't just import Mikado on top, because templates are nested in different folders and I would like to support the browser native ES6 module resolution. The ES5 version bundles everything on window.Mikado, that's why es5 compiled templates will automatically register (they need, because here we can't import).

@hsnoil
Copy link
Author

hsnoil commented Jan 22, 2024

So how about an optional flag that if someone wants to bundle their stuff it would register it?

@ts-thomas
Copy link
Collaborator

That sounds good. I will add a compiler flag to set Mikado source root, so it can automatically register then. 👍

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

No branches or pull requests

2 participants