“Grep”, picing up a variable’s data

| No Comments | No TrackBacks

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>
 

No TrackBacks

TrackBack URL: http://www.mt-j.info/mt/mt-tb.cgi/92

Leave a comment

About this Entry

This page contains a single entry by nick published on March 20, 2010 10:00 PM.

“Pagebute”, a pagination plugin for Movable Type was the previous entry in this blog.

Old version of Movable Type is the next entry in this blog.

Find recent content on the main index or look in the archives to find all content.