Skip to content

mo-zag/watcher

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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
%html
  %head
    %title
       Haml & Sass Watcher for PHP developers
  %body
    %h1
      <?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


%content
  %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


#content
  %p
    PHP block code example
  :plain
    <?php function helloworld()
      {
          $haml = "Hellow world";
          return $haml;
      }
      ?>
  #wrapper
    <?php helloworld(); ?>

About

watches haml sass

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published