Movable Typeのテンプレートで置換した値をそのまま出力するのではなく、変数に格納しようとして迷うことがあったのでメモ。
サンプルコード
演算処理をする際はMTSetVarで演算結果をそのまま再代入できるので、同じようにできるかと思ったのですが、その後で出力を試してみても何も出力されない(再代入時に空文字列を代入している?)ようでした。
<$mt:SetVar name="url" value="https://example.com/about/"$> <$mt:SetVar name="url" replace="https://example.com/","/"$> <$mt:Var name="url"$> <$mt:SetVar name="text" value="あいうえおあいうえお"$> <$mt:SetVar name="text" regex_replace="/あ/","か"$> <$mt:Var name="text"$>
調べた結果、MTVarにsetvarモディファイアを使うことで、結果が出力されず指定した変数に格納されるようでした。
<$mt:SetVar name="url" value="https://example.com/about/"$> <$mt:Var name="url" replace="https://example.com/","/" setvar="url"$> <$mt:Var name="url"$> <$mt:SetVar name="text" value="あいうえおあいうえお"$> <$mt:Var name="text" regex_replace="/あ/","か" setvar="text"$> <$mt:Var name="text"$>
以下のように出力できました。
/about/ かいうえおあいうえお
コメントが承認されるまで時間がかかります。