Using global modifier to sanitize html file

| No Comments | No TrackBacks

Watanabe, an author of "45-shiki", wrote an entry about the global modifier.

In this entry, he introduced his original global modifier, and introduced some sample codes.

45shiki

For example, he writs regular expression to sanitize a html file, to delete blank characters.

As you may know, a html file, which is genelated by Movable Type template, includes many blank characters. It is created from MT's tags.

In the entry, he wrote three ways to delete blank characters.

Let's see the first code.

<MTIf tag="BlogID" regex_replace="/\s+\n/g","\n">
<html>
   <body> 
      foo,bar 
   </body>
</html>
</MTIf>

In this code, he uses <mt:if> block tags. An argument, tag="Blog_Id" retrurns true value. Then modifier will be effective for the sandwiched code by <mt:if>.

Here is the second sample code

<MTUnless regex_replace="/\s+\n/g","\n">
<html>
   <body>
      foo,bar
   </body>
</html>
</MTUnless>

In this code, he uses <mt:unless>. <mt:unless> always returns false if an argument is not defined. Then, the modifier will be effective for the sandwiched code.

And this is the third sample code.

<MTFor regex_replace="/\s+\n/g","\n">
<html>
   <body>
      foo, bar
   </body>
</html>
</MTFor>

<mt:for> tags are executed only once, if there are is no argument value. So the sample code is executed only once.

No TrackBacks

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

Leave a comment

About this Entry

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

I updated an entry about "UploadDir", by courtesy of Matthew was the previous entry in this blog.

"rebuild_all", rebuilding all blogs from command script is the next entry in this blog.

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