How do you separate Mint code in a plurality of files (or how do you "import" code between Mint files) ? #561
-
How do you separate Mint code in a plurality of files (or how do you "import" code between Mint files) ? For instance, how would you put the module Greet in a separate file and call it in the main module file component Main {
fun render : Html {
<div>
<button onClick={Greet.hello}>
"Click here"
</button>
</div>
}
}
module Greet {
fun hello(event : Html.Event) {
Debug.log("Hello")
}
} |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Every Mint project has a All
Just create a new file |
Beta Was this translation helpful? Give feedback.
Every Mint project has a
mint.json
file which specifies the directories which contain source code: https://github.com/mint-lang/mint-realworld/blob/master/mint.json#L4All
*.mint
files are parsed in the source directories and all entities are available in all files, so there is no need to import.Just create a new file
Greet.mint
(the name doesn't matter) in thesource
directory (which is the default) put the module there and that's it.