6
7

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

regex_replace のご利用は計画的に

Posted at

Movable Type のテンプレートで、記事の内容を操作したいときに、グローバルフィルタの regex_replace をどうしても使いたいときがあります。しかし、いささか重いのです。たくさんあると、重くなってテンプレートの編集や再構築がとても遅くなってしまうことがあります。

<mt:EntryBody regex_replace="<img ","<amp-img " regex_replace="<iframe ","<amp-iframe " >
<mt:EntryMore regex_replace="<img ","<amp-img " regex_replace="<iframe ","<amp-iframe " >

こういうように同じ regex_replace が続くときには

<mt:Unless
    regex_replace="<img ","<amp-img "
    regex_replace="<iframe ","<amp-iframe "
    regex_replace="<audio ">,"<amp-audio "
    regex_replace="<video ">,"<amp-video "
>
  <mt:EntryBody>
  <mt:EntryMore>
</mt:Unless>

のように、なにもしない<mt:Unless>コンテナタグに入れてしまうと、mt:EntryBodymt:EntryMore の両方に対して、一回の処理で済むので、再構築も早くなります。おすすめです。

6
7
2

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
6
7

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?