https://github.com/sake92/mill-hepek
Mill plugin for rendering Scala objects to files
https://github.com/sake92/mill-hepek
Last synced: over 1 year ago
JSON representation
Mill plugin for rendering Scala objects to files
- Host: GitHub
- URL: https://github.com/sake92/mill-hepek
- Owner: sake92
- License: apache-2.0
- Created: 2023-11-28T14:04:44.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2025-02-20T07:58:39.000Z (over 1 year ago)
- Last Synced: 2025-03-26T00:51:15.481Z (over 1 year ago)
- Language: Scala
- Size: 41 KB
- Stars: 4
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# mill-hepek
[](https://maven-badges.herokuapp.com/maven-central/ba.sake/mill-hepek)
Mill plugin for writing Scala `object`s to files.
See also [**hepek**](https://github.com/sake92/hepek), static content generator that builds upon this plugin.
## Installation
Add the following to your `build.sc`:
```scala
import $ivy.`ba.sake::mill-hepek::0.0.2`
import mill._
import mill.scalalib._
import ba.sake.millhepek.MillHepekModule
object site extends MillHepekModule with ScalaModule {
def scalaVersion = ...
}
```
Then you can run `./mill site.hepek`
## Usage
When you run `./mill site.hepek` it will:
1. write all `object .. extends Renderable` from the `files` package to `site/hepek_output` folder
1. copy all files from `src/resources/public` to `hepek_output` folder
1. write static accessors for `src/resources/public` files, so you don't have to type them with strings and make silly mistakes
Minimal example:
```scala
package files // mandatory !!
import java.nio.file.Paths
import ba.sake.hepek.core.Renderable
object RenderMe extends Renderable {
// access `src/resources/public` files through autogenerated files.
override def render =
"Some text" // arbitrary Scala code
override def relPath =
Paths.get("renderme.txt")
}
```
When you run `./mill site.hepek`, you'll find the `site/hepek_output/renderme.txt` file,
with text `Some text`.
---
## Examples
- [sake.ba website source]([https://github.com/sake92/hepek-examples](https://github.com/sake92/sake-ba-source))
- [examples](https://github.com/sake92/hepek-examples)
- ["Philosophy"](https://dev.to/sake_92/render-static-site-from-scala-code)
---
## Fun fact
I think that this is the first project that tried this approach, using first-class Scala `object`s for this kind of stuff.
Correct me if I'm wrong... ^_^
---
## About the name
A "hepek" in Bosnian language is a jargon for a thing/thingy/stuff...
It is used when we don't know the name of a thing: "Give me that ... *hepek*".
Also, it is used in the famous show called "Top lista nadrealista" as a name for an advanced device which calms down situations of various kinds.