用Haml(Ruby)转换后,Php文件呈现空白!

时间:2010-06-23 04:00:55

标签: php haml

为了测试转换后的index.haml是否适用于我的wamp和localhost,我做了以下事情:

  1. 首先,我将我的ndex.php重命名为index.html
  2. 然后,我在命令行中键入html2haml index.html index.haml
  3. 然后,我在命令行中输入了haml index.haml indexnew.html
  4. 我将indexnew.html重命名为indexnew.php
  5. 我测试了它:localhost/projects/cross-browser/base0.9/indexnew.php
  6. 但是,即使里面的代码没问题,indexnew.php仍然是空白的:

    原始Php(index.php):

     <?php
        include_once 'localization.php';
        ?>
        <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
        <html>
        <head>
         <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
         <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7"/>
         <title>Alex Chen - Web Development, Graphic Design, and Translation</title>
         <link rel="stylesheet" type="text/css" href="styles/reset.css" />
         <link rel="stylesheet" type="text/css" href="styles/global.css" />
         <link rel="stylesheet" type="text/css" href="fancybox/jquery.fancybox-1.3.1.css" />
         <?php if($lang_file=='lang.zh-tw.php' || $lang_file=='lang.zh-cn.php') {echo '<link rel="stylesheet" type="text/css" href="styles/chinese.css" />';} ?>
         <script type="text/javascript" src="scripts/jquery-1.3.2.min.js"></script>
         <script type="text/javascript" src="scripts/jquery.validate.js"></script>
         <script type="text/javascript" src="fancybox/jquery.fancybox-1.3.1.pack.js"></script>
         <script type="text/javascript" src="scripts/jquery.scrollTo-min.js"></script>
         <script type="text/javascript" src="scripts/jquery.localscroll-min.js"></script>
         <script type="text/javascript" src="scripts/custom.js"></script>
         <?php if($lang_file=='lang.en.php') {echo '<script type="text/javascript" src="scripts/jquery-validate/val-en.js"></script>';} ?>
         <?php if($lang_file=='lang.es.php') {echo '<script type="text/javascript" src="scripts/jquery-validate/val-es.js"></script>';} ?>
         <?php if($lang_file=='lang.zh-tw.php') {echo '<script type="text/javascript" src="scripts/jquery-validate/val-zh-tw.js"></script>';} ?>
         <?php if($lang_file=='lang.zh-cn.php') {echo '<script type="text/javascript" src="scripts/jquery-validate/val-zh-cn.js"></script>';} ?>
        </head>
        <body id="home">
        <div id="header">
         <div class="container">
          <div id="banner">
           <ul id="lang">
            <li <?php if($lang_file=='lang.en.php') {echo 'class="current"';} ?>><a href="index.php?lang=en">ENGLISH</a></li>
            <li <?php if($lang_file=='lang.es.php') {echo 'class="current"';} ?>><a href="index.php?lang=es"><?php echo l('nav_a0'); ?></a></li>
            <li <?php if($lang_file=='lang.zh-tw.php') {echo 'class="current"';} ?>><a href="index.php?lang=zh-tw"><?php echo l('nav_a1'); ?></a></li>
            <li <?php if($lang_file=='lang.zh-cn.php') {echo 'class="current"';} ?>><a href="index.php?lang=zh-cn"><?php echo l('nav_a2'); ?></a></li>
           </ul>
           <div id="logo">
            <h1><a>ALEXCHEN</a></h1>
           </div>
           <div id="logo2">
            <ul id="nav">
             <li><a href="#content"><?php echo l('nav1'); ?></a></li>
             <li><a href="#contact"><?php echo l('nav2'); ?></a></li>
            </ul>
           </div>
           <div id="logo3">
           </div>
          </div><!-- #header-bottom -->
         </div><!-- .container -->
        </div><!-- #header -->
        <div id="content">
         <div class="container">
          <div class="showcase">
          <div class="first">
            <div id="nopic">
             <p><?php echo l('tagline_p'); ?></p>
            </div>
           </div>
           <div class="pusher">
            <h3><?php echo l('showcase1_h3'); ?></h3>
            <p><?php echo l('showcase1_p'); ?></p>
            <div class="pic">
             <a id="showcase1" href="#inline1"><img src="images/showcase1t.png"/></a>
             <div id="inline1">
              <img src="images/showcase1.png"/>
              <a href="http://studyatbest.com">studyatbest.com</a>
             </div>
            </div>
           </div>
           <div class="pusher">
            <h3><?php echo l('showcase2_h3'); ?></h3>
            <p><?php echo l('showcase2_p'); ?></p>
            <div class="pic">
             <a id="showcase2" href="#inline2"><img src="images/showcase2t.png"/></a>
             <div id="inline2">
              <img src="images/showcase2.png"/>
              <a href="http://studyatbes.com">spacestudios.com</a>
             </div>
            </div>
           </div><!-- .pushed -->
           <div class="pusher">
            <h3><?php echo l('showcase3_h3'); ?></h3>
            <p><?php echo l('showcase3_p'); ?></p>
            <div class="pic">
             <a id="showcase3" href="#inline3"><img src="images/showcase3t.png"/></a>
             <div id="inline3">
              <img src="images/showcase3.png"/>
              <a href="http://studyatbes.com">alexchen.com</a>
             </div>
            </div>
           </div>
           <div class="pusher">
            <h3><?php echo l('showcase4_h3'); ?></h3>
            <p><?php echo l('showcase4_p'); ?></p>
            <div class="pic">
             <a id="showcase4" href="#inline4"><img src="images/showcase4t.png"/></a>
             <div id="inline4">
              <img src="images/showcase4.png"/>
              <a href="http://studyatbes.com">mattsai.com</a>
             </div>
            </div>
           </div>
           <div class="pusher">
            <h3><?php echo l('showcase5_h3'); ?></h3>
            <p><?php echo l('showcase5_p'); ?></p>
            <div class="pic">
             <a id="showcase5" href="#inline5"><img src="images/showcase5t.png"/></a>
             <div id="inline5">
              <img src="images/showcase5.png"/>
              <a href="http://studyatbes.com">mattsai.com</a>
             </div>
            </div>
           </div><!-- .pusher -->
           <div class="pusher">
            <h3><?php echo l('showcase6_h3'); ?></h3>
            <p><?php echo l('showcase6_p'); ?></p>
            <div class="pic">
             <a id="showcase6" href="#inline6"><img src="images/showcase6t.png"/></a>
             <div id="inline6">
              <img src="images/showcase6.png"/>
              <a href="http://studyatbes.com">mattsai.com</a>
             </div>
            </div>
           </div>
           <div class="pusher">
            <h3><?php echo l('showcase8_h3'); ?></h3>
            <p><?php echo l('showcase8_p'); ?></p>
            <div class="pic">
             <a id="showcase8" href="#inline8"><img src="images/showcase8t.png"/></a>
             <div id="inline8">
              <img src="images/showcase8.png"/>
              <a href="http://studyatbes.com">mattsai.com</a>
             </div>
            </div>
           </div><!-- .pusher -->
          </div><!-- .showcase -->
         </div><!-- .container -->
        </div><!-- #work -->
        <div id="footer">
         <div class="container">
          <div id="footer-top">
           <div id="about">
           <h3><?php echo l('about_h3'); ?></h3>
           <p><?php echo l('about_p'); ?></p>
           </div>
           <div id="info">
           <h3><?php echo l('info_h3'); ?></h3>
            <ul>
             <li id="tel"><?php echo l('_info_li2'); ?><p>Tel:</p> 0918051170</li>
             <li id="gmail"><?php echo l('_info_li3'); ?><p></p><a href="mailto:janoochen@gmail.com">alexchen.net@gmail.com</a></li>
             <li id="facebook"><?php echo l('_info_li4'); ?> <a href="http://www.facebook.com/weedd.chen">facebook</a></li>
            </ul>
           </div>
           <div id="contact">
            <h3><?php echo l('contact_h3'); ?></h3>
            <p><?php echo l('_contact_p'); ?></p>
            <form id="sendmail" method="post" action="http://www.emailmeform.com/fid.php?formid=254816">
            <label for="name"><?php echo l('form_label1'); ?></label>
             <input type="text"  id="name" name="FieldData0" />
             <label for="email"><?php echo l('form_label2'); ?></label>
             <input type="text"  id="email" name="FieldData1" />
             <label for="message"><?php echo l('form_label3'); ?></label>
             <textarea type="text" id="message" name="FieldData2"></textarea>
             <input id="button" type="submit" value="<?php echo l('submit'); ?>">
            </form>
           </div>
          </div><!-- #footer-top -->
          <div id="footer-bottom">
           <p>Copyright © 2010 Alex Chen. All Rights Reserved. Hosted on <a href="http://www.zymic.com">Zymic</a>. Contact form hosted on <a href="http://www.emailmeform.com">Email Me Form</a>.<a id="nr" href="http://www.freedomain.co.nr/cheap_web_hosting.php" target="_blank"><img src="http://ruarmza.4u.com.ru/ch.gif" alt="Cheap Web Hosting Providers" width="88" height="31" border="0" /></a></p>
          </div>
         </div><!-- .container -->
        </div><!-- #footer -->
        <script type="text/javascript" src="scripts/google-analytics.js"></script>
        <script type="text/javascript" src="scripts/page-tracker.js"></script>
        </body>
        </html>
    

    转换后的Php(indexnew.php):

    <?php include_once 'localization.php';
    ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html>
      <head>
        <meta content='text/html; charset=utf-8' http-equiv='Content-Type' />
        <meta content='IE=EmulateIE7' http-equiv='X-UA-Compatible' />
        <title>Alex Chen - Web Development, Graphic Design, and Translation</title>
        <link href='styles/reset.css' rel='stylesheet' type='text/css' />
        <link href='styles/global.css' rel='stylesheet' type='text/css' />
        <link href='fancybox/jquery.fancybox-1.3.1.css' rel='stylesheet' type='text/css' />
        <?php if($lang_file=='lang.zh-tw.php' || $lang_file=='lang.zh-cn.php') {echo '<link rel="stylesheet" type="text/css" href="styles/chinese.css" ?>
        ';} ?>
        <script src='scripts/jquery-1.3.2.min.js' type='text/javascript'></script>
        <script src='scripts/jquery.validate.js' type='text/javascript'></script>
        <script src='fancybox/jquery.fancybox-1.3.1.pack.js' type='text/javascript'></script>
        <script src='scripts/jquery.scrollTo-min.js' type='text/javascript'></script>
        <script src='scripts/jquery.localscroll-min.js' type='text/javascript'></script>
        <script src='scripts/custom.js' type='text/javascript'></script>
        <?php if($lang_file=='lang.en.php') {echo '<script type="text/javascript" src="scripts/jquery-validate/val-en.js?>
        ';} ?>
        <?php if($lang_file=='lang.es.php') {echo '<script type="text/javascript" src="scripts/jquery-validate/val-es.js?>
        ';} ?>
        <?php if($lang_file=='lang.zh-tw.php') {echo '<script type="text/javascript" src="scripts/jquery-validate/val-zh-tw.js?>
        ';} ?>
        <?php if($lang_file=='lang.zh-cn.php') {echo '<script type="text/javascript" src="scripts/jquery-validate/val-zh-cn.js?>
        ';} ?>
      </head>
      <body id='home'>
        <div id='header'>
          <div class='container'>
            <div id='banner'>
              <ul id='lang'>
                <li
                <?php if($lang_file=='lang.en.php') {echo 'class="current"';} ?>
                >
              </ul>
              <a href='index.php?lang=en'>ENGLISH</a>
              <li
              <?php if($lang_file=='lang.es.php') {echo 'class="current"';} ?>
              >
              <a href='index.php?lang=es'>
                <?php echo l('nav_a0'); ?>
              </a>
              <li
              <?php if($lang_file=='lang.zh-tw.php') {echo 'class="current"';} ?>
              >
              <a href='index.php?lang=zh-tw'>
                <?php echo l('nav_a1'); ?>
              </a>
              <li
              <?php if($lang_file=='lang.zh-cn.php') {echo 'class="current"';} ?>
              >
              <a href='index.php?lang=zh-cn'>
                <?php echo l('nav_a2'); ?>
              </a>
              <div id='logo'>
                <h1>
                  <a>ALEXCHEN</a>
                </h1>
              </div>
              <div id='logo2'>
                <ul id='nav'>
                  <li>
                    <a href='#content'>
                      <?php echo l('nav1'); ?>
                    </a>
                  </li>
                  <li>
                    <a href='#contact'>
                      <?php echo l('nav2'); ?>
                    </a>
                  </li>
                </ul>
              </div>
              <div id='logo3'></div>
            </div>
            <!-- #header-bottom -->
          </div>
          <!-- .container -->
        </div>
        <!-- #header -->
        <div id='content'>
          <div class='container'>
            <div class='showcase'>
              <div class='first'>
                <div id='nopic'>
                  <p>
                    <?php echo l('tagline_p'); ?>
                  </p>
                </div>
              </div>
              <div class='pusher'>
                <h3>
                  <?php echo l('showcase1_h3'); ?>
                </h3>
                <p>
                  <?php echo l('showcase1_p'); ?>
                </p>
                <div class='pic'>
                  <a href='#inline1' id='showcase1'>
                    <img src='images/showcase1t.png' />
                  </a>
                  <div id='inline1'>
                    <img src='images/showcase1.png' />
                    <a href='http://studyatbest.com'>studyatbest.com</a>
                  </div>
                </div>
              </div>
              <div class='pusher'>
                <h3>
                  <?php echo l('showcase2_h3'); ?>
                </h3>
                <p>
                  <?php echo l('showcase2_p'); ?>
                </p>
                <div class='pic'>
                  <a href='#inline2' id='showcase2'>
                    <img src='images/showcase2t.png' />
                  </a>
                  <div id='inline2'>
                    <img src='images/showcase2.png' />
                    <a href='http://studyatbes.com'>spacestudios.com</a>
                  </div>
                </div>
              </div>
              <!-- .pushed -->
              <div class='pusher'>
                <h3>
                  <?php echo l('showcase3_h3'); ?>
                </h3>
                <p>
                  <?php echo l('showcase3_p'); ?>
                </p>
                <div class='pic'>
                  <a href='#inline3' id='showcase3'>
                    <img src='images/showcase3t.png' />
                  </a>
                  <div id='inline3'>
                    <img src='images/showcase3.png' />
                    <a href='http://studyatbes.com'>alexchen.com</a>
                  </div>
                </div>
              </div>
              <div class='pusher'>
                <h3>
                  <?php echo l('showcase4_h3'); ?>
                </h3>
                <p>
                  <?php echo l('showcase4_p'); ?>
                </p>
                <div class='pic'>
                  <a href='#inline4' id='showcase4'>
                    <img src='images/showcase4t.png' />
                  </a>
                  <div id='inline4'>
                    <img src='images/showcase4.png' />
                    <a href='http://studyatbes.com'>mattsai.com</a>
                  </div>
                </div>
              </div>
              <div class='pusher'>
                <h3>
                  <?php echo l('showcase5_h3'); ?>
                </h3>
                <p>
                  <?php echo l('showcase5_p'); ?>
                </p>
                <div class='pic'>
                  <a href='#inline5' id='showcase5'>
                    <img src='images/showcase5t.png' />
                  </a>
                  <div id='inline5'>
                    <img src='images/showcase5.png' />
                    <a href='http://studyatbes.com'>mattsai.com</a>
                  </div>
                </div>
              </div>
              <!-- .pusher -->
              <div class='pusher'>
                <h3>
                  <?php echo l('showcase6_h3'); ?>
                </h3>
                <p>
                  <?php echo l('showcase6_p'); ?>
                </p>
                <div class='pic'>
                  <a href='#inline6' id='showcase6'>
                    <img src='images/showcase6t.png' />
                  </a>
                  <div id='inline6'>
                    <img src='images/showcase6.png' />
                    <a href='http://studyatbes.com'>mattsai.com</a>
                  </div>
                </div>
              </div>
              <div class='pusher'>
                <h3>
                  <?php echo l('showcase8_h3'); ?>
                </h3>
                <p>
                  <?php echo l('showcase8_p'); ?>
                </p>
                <div class='pic'>
                  <a href='#inline8' id='showcase8'>
                    <img src='images/showcase8t.png' />
                  </a>
                  <div id='inline8'>
                    <img src='images/showcase8.png' />
                    <a href='http://studyatbes.com'>mattsai.com</a>
                  </div>
                </div>
              </div>
              <!-- .pusher -->
            </div>
            <!-- .showcase -->
          </div>
          <!-- .container -->
        </div>
        <!-- #work -->
        <div id='footer'>
          <div class='container'>
            <div id='footer-top'>
              <div id='about'>
                <h3>
                  <?php echo l('about_h3'); ?>
                </h3>
                <p>
                  <?php echo l('about_p'); ?>
                </p>
              </div>
              <div id='info'>
                <h3>
                  <?php echo l('info_h3'); ?>
                </h3>
                <ul>
                  <li id='tel'>
                    <?php echo l('_info_li2'); ?>
                    <p>Tel:</p>
                    0918051170
                  </li>
                  <li id='gmail'>
                    <?php echo l('_info_li3'); ?>
                    <p></p>
                    <a href='mailto:janoochen@gmail.com'>alexchen.net@gmail.com</a>
                  </li>
                  <li id='facebook'>
                    <?php echo l('_info_li4'); ?>
                    <a href='http://www.facebook.com/weedd.chen'>facebook</a>
                  </li>
                </ul>
              </div>
              <div id='contact'>
                <h3>
                  <?php echo l('contact_h3'); ?>
                </h3>
                <p>
                  <?php echo l('_contact_p'); ?>
                </p>
                <form action='http://www.emailmeform.com/fid.php?formid=254816' id='sendmail' method='post'>
                  <label for='name'>
                    <?php echo l('form_label1'); ?>
                  </label>
                  <input id='name' name='FieldData0' type='text' />
                  <label for='email'>
                    <?php echo l('form_label2'); ?>
                  </label>
                  <input id='email' name='FieldData1' type='text' />
                  <label for='message'>
                    <?php echo l('form_label3'); ?>
                  </label>
                  <textarea id='message' name='FieldData2' type='text'></textarea>
                  <input id='button' type='submit' value="&lt;?php echo l('submit'); ?&gt;" />
                </form>
              </div>
            </div>
            <!-- #footer-top -->
            <div id='footer-bottom'>
              <p>
                Copyright © 2010 Alex Chen. All Rights Reserved. Hosted on
                <a href='http://www.zymic.com'>Zymic</a>.
                Contact form hosted on
                <a href='http://www.emailmeform.com'>Email Me Form</a>.
                <a href='http://www.freedomain.co.nr/cheap_web_hosting.php' id='nr' target='_blank'>
                  <img alt='Cheap Web Hosting Providers' border='0' height='31' src='http://ruarmza.4u.com.ru/ch.gif' width='88' />
                </a>
              </p>
            </div>
          </div>
          <!-- .container -->
        </div>
        <!-- #footer -->
        <script src='scripts/google-analytics.js' type='text/javascript'></script>
        <script src='scripts/page-tracker.js' type='text/javascript'></script>
      </body>
    </html>
    

    有什么建议吗?

1 个答案:

答案 0 :(得分:1)

我建议您尝试使用特定于PHP的HAML版本,例如PHPHamlpHAML。 Ruby HAML解释器特别期待Ruby代码,并且可能会搞砸你的PHP语法。

话虽如此,我已经使用Chaml取得了一定程度的成功。 HAML for PHP处于一个相当实验阶段,你遇到错误。如果您正在编写比PHP更多的HTML,那么它可以提供很大的帮助。