watches haml sass
PHP Ruby
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


Haml & Sass Watcher for PHP developers

To use Watcher download source code open config.rb

  • Change properties to match your machine
  • Open your command line and navigate to the folder where you downloaded the source and run rake watch
  • Open the haml-sass directory (or in the codeigniter example the haml folder) and edit index.haml or index.phaml make a change save it
  • phaml files will be saved as .php files, haml files will be saved as .html files
  • Open the php directory or your codeigniter views directory folder and open index.html or index.php in your editor to view your changes.

Syntax demo Haml - PHP

<?php $heading = "Haml & Sass Watcher for PHP develope"; ?>
!!! Strict
       Haml & Sass Watcher for PHP developers
      <?php echo $heading; ?>

Stop Haml from escaping PHP opening closing brackets

In some cases we would like to add our php code to be in a html attribute

  %p{ :id => "<?php echo 'paragraph'; ?>" }

but the Haml parser by default escapes PHP opening and closing brackets. Work around is to hack the Haml code to do this find the haml folder inside your gems folder open haml-3.0.11\lib\haml\helpers.rb find

NOTE: If you have HAML 3.1.4 you can set in config file @hamloptions = {:attr_wrapper => '"', :escape_attrs => false } to stop HAML from escaping charactersif you have a previouse version you canfollow the instructions bellow.

HTML_ESCAPE = { '&'=>'&', '<'=>'<', '>'=>'>', '"'=>'"', "'"=>''', }

Comment out the existing code and add the code below

#HTML_ESCAPE = { '&'=>'&', '<'=>'<', '>'=>'>', '"'=>'"', "'"=>''', }
HTML_ESCAPE = { '&'=>'&', '<'=>'<', '>'=>'>', '"'=>'"', "'"=>''', }

NOTE: Make sure you just comment the existing code, so you can go back to this when not using PHP.

Add a block of PHP code without having to indent the code

Just add :plain tag and Haml will render the code below this tag as you write see example below

    PHP block code example
    <?php function helloworld()
          $haml = "Hellow world";
          return $haml;
    <?php helloworld(); ?>