LoginSignup
13
3

More than 5 years have passed since last update.

Mint - SPA に特化した言語

Last updated at Posted at 2018-07-25

Mint という、 SPA のための新しいフレームワークがあり、まとめてみた。

2018/07/25 現在では、 Alpha Stage である。

いつかちゃんと使ってみたい。

特徴

  • SPA に特化している
    • 一つのファイル (モジュール) に、 HTML / CSS / JS を書く
    • React + CSS Module っぽいかも
    • Store をデフォルトでサポート
    • ルーティングもデフォルトでサポート
  • 関数型っぽい書き方のサポート
    • Pipe 構文
    • Case 式
  • 静的な型( record と呼んでいる)サポート
  • Crystal で書かれており、JSに依存していないっぽい?
    • package.json の代わりに mint.json
  • 依存が少ない
    • 全て Built In なので、 なんとかloader みたいな概念が無いっぽい
  • パッケージマネージャなどの拡張はこれからのよう

HTML を出力する

component Test {
  property size : String = "small"
  property color : String = "red"

  fun render : Html {
    <div>
      <{ color }>
      <{ size }>
    </div>
  }
}

スタイリング

component Main {
  style button {
    background: red;
    color: white;
    border: 0;
  }

  fun render : Html {
    <button::button>
      <{ "Click ME!" }>
    </button>
  }
}

レコード( Struct 的な)の定義

record User {
  email : String,
  name : String,
  id : Number
}

型指定

  fun renderGreeting (name : String, greeter : Function(String, Html)) : Html {
    greeter(name)
  }

関数型っぽい書き方ができる

case (condition) {
  match1 => value1
  match2 => value2
  match3 => value3
  => defaultValue
}

"blah"
|> Number.fromString()
|> Result.isError() # true

感想

こういう All-in-One 的なフレームワークは、ロックインしてしまう心配があるが、どうなのだろう。

13
3
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
13
3