Okayama, an author of “weeeblog+”, have developed a new plugin, “Grep”.
It allows you to pick up an arbitrary variable’s data , and make a conditional logic by it.
Technical, but useful plugin for developers.
You can download this plugin directly from here.
These are provided tags by “Grep”.
<MTIfGrep>, <MTUnlressGrep>,<MTGrep>
Also, a sample code.
<MTIgnore> setting template variables to hash</MTIgnore>
<$MTSetVar name="array" value="test1" function="push"$>
<$MTSetVar name="array" value="test2" function="push"$>
<$MTSetVar name="array" value="test3" function="push"$>
<$MTSetVar name="array" value="test1test2" function="push"$>
<$MTSetVar name="array" value="test3test4" function="push"$>
<MTIgnore>searching for “test3” </MTIgnore>
<$MTSetVar name="search" value="test3"$>
<MTIfGrep name="array" grep="$search">
Match!
<MTElse>
Not Match!
</MTIfGrep>
<$MTSetVar name="search" value="test3"$>
<MTUnlessGrep name="array" grep="$search">
Not Match!
<MTElse>
Match!
</MTUnlessGrep>
<MTIgnore> serching for “3” by regex </MTIgnore>
<$MTSetVar name="search" value="/3/"$>
<MTIfGrep name="array" grep="$search">
Match!
<MTElse>
Not Match!
</MTIfGrep>
<$MTSetVar name="search" value="/3/"$>
<MTUnlessGrep name="array" grep="$search">
Not Match!
<MTElse>
Match!
</MTUnlessGrep>
<MTIgnore> searching for “test3”</MTIgnore>
<MTIgnore> loop by MTLoop if there is the value </MTIgnore>
<$MTSetVar name="search" value="test3"$>
<MTGrep name="array" grep="$search">
Match: <$MTVar name="__value__"$>
<MTElse>
Not Match!
</MTGrep>
<MTIgnore> searching for “testtest” by regex </MTIgnore>
<MTIgnore> loop by MTLoop when there is the matched value </MTIgnore>
<$MTSetVar name="search" value="/testtest/"$>
<MTGrep name="array" grep="$search">
Match: <$MTVar name="__value__"$>
<MTElse>
Not Match!
</MTGrep>
<MTIgnore> searching for “TEST” whether it is an upper or lower case, by optinoal value “i” </MTIgnore>
<MTIgnore> loop by MTLoop when there is the matched value</MTIgnore>
<$MTSetVar name="search" value="/TEST/i"$>
<MTGrep name="array" grep="$search">
Match: <$MTVar name="__value__"$>
<MTElse>
Not Match!
</MTGrep>
Leave a comment