hyogen-md

0.10.0

宣言と代入

hyogen ブロック内では、JavaScript と同様に constlet で変数を宣言できます。

<!--@hg

const text = "foo bar"
let fooBar = "over-writable"
fooBar = "over-written"

const object = {
  animal: "duck",
  state: "sitting",
}

@endhg-->

- {{ text }}
- {{ fooBar }}
- {{ object.animal }} is {{ object.state }}

出力:

- foo bar
- over-written
- duck is sitting

使えるもの

種別内容
宣言const / let
再代入fooBar = "new value"
更新++ / --、複合代入(+= など)
リテラル数値、文字列、真偽、nullundefined、配列、オブジェクト
テンプレートリテラル`hello ${name}`
スプレッド...

使えないもの

種別内容
関数定義function / =>
ループwhilefor…offor…in
モジュールimport / require
その他try / catchnew、分割代入
正規表現リテラル/foo/

C 風ループ

for (init; cond; update)do { ... } while (cond) は hyogen ブロック内で使えます。

<!--@hg
let sum = 0
for (let i = 0; i < 3; i++) {
  sum += i
}
@endhg-->

Sum: {{ sum }}

予約語

次の語は識別子として使えません:

if else else if endif const let for do while each endeach block endblock extend include component as

関連