tags:

views:

29

answers:

1

In order to test if the converted index.haml would work on with my wamp and localhost i did the following:

  1. First, I renamed my index.php into index.html
  2. Then, I typed html2haml index.html index.haml in the command line
  3. Then, I typed haml index.haml indexnew.html in the command line
  4. I renamed indexnew.html to indexnew.php
  5. I tested it: localhost/projects/cross-browser/base0.9/indexnew.php

but the indexnew.php was rendered blank even if the code inside is ok:

Original 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"&gt;
    <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"&gt;studyatbest.com&lt;/a&gt;
         </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"&gt;spacestudios.com&lt;/a&gt;
         </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"&gt;alexchen.com&lt;/a&gt;
         </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"&gt;mattsai.com&lt;/a&gt;
         </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"&gt;mattsai.com&lt;/a&gt;
         </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"&gt;mattsai.com&lt;/a&gt;
         </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"&gt;mattsai.com&lt;/a&gt;
         </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:[email protected]">[email protected]</a></li>
         <li id="facebook"><?php echo l('_info_li4'); ?> <a href="http://www.facebook.com/weedd.chen"&gt;facebook&lt;/a&gt;&lt;/li&gt;
        </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"&gt;
        <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"&gt;Zymic&lt;/a&gt;. Contact form hosted on <a href="http://www.emailmeform.com"&gt;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>

Converted 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"&gt;
<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'&gt;studyatbest.com&lt;/a&gt;
              </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'&gt;spacestudios.com&lt;/a&gt;
              </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'&gt;alexchen.com&lt;/a&gt;
              </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'&gt;mattsai.com&lt;/a&gt;
              </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'&gt;mattsai.com&lt;/a&gt;
              </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'&gt;mattsai.com&lt;/a&gt;
              </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'&gt;mattsai.com&lt;/a&gt;
              </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:[email protected]'>[email protected]</a>
              </li>
              <li id='facebook'>
                <?php echo l('_info_li4'); ?>
                <a href='http://www.facebook.com/weedd.chen'&gt;facebook&lt;/a&gt;
              </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'&gt;Zymic&lt;/a&gt;.
            Contact form hosted on
            <a href='http://www.emailmeform.com'&gt;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>

Any suggestions?

+1  A: 

I'd suggest you try a PHP-specific version of HAML, like PHPHaml or pHAML. The Ruby HAML interpreter is specifically expecting Ruby code, and will likely screw up your PHP syntax.

Having said that, I have used Chaml with some degree of success. HAML for PHP is at a rather experimental stage, and you will come across bugs. If you're writing more HTML than PHP though, it can be a great help.

deceze