Skip to content

Instantly share code, notes, and snippets.

@coderek
Created September 30, 2013 05:29
Show Gist options
  • Save coderek/6759673 to your computer and use it in GitHub Desktop.
Save coderek/6759673 to your computer and use it in GitHub Desktop.
# HAML is a language that can be compiled to HTML
# it's syntax is easy to write and read, thus it's very popular among web developers
# grab zipped gem from https://github.com/haml/haml/archive/master.zip
# also the dependency https://github.com/rtomayko/tilt/archive/master.zip
# command to compile
# `jrubyc haml.rb`
# command to run
# `java -cp .:/path/to/jruby-complete-1.7.4.jar haml`
# include dependencies
$:.unshift("D:\\haml-master\\lib") # replace with your unzipped lib folder path (absolute path)
$:.unshift("D:\\tilt-master\\lib") # replace with your unzipped lib folder path (absolute path)
require "haml"
# some simple syntax
# http://haml.info/
# simple plain haml
haml1 = <<EOS
#foo Hello!
EOS
# this template contains varaibles
haml2 = <<EOS
%section.container
%h1= title
%h2= subtitle
.content
= content
EOS
puts "\n"
puts "================haml1 output======================"
puts "\n"
e1 = Haml::Engine.new(haml1)
puts e1.render # some html
puts "\n"
puts "================haml2 output======================"
puts "\n"
e2 = Haml::Engine.new(haml2)
puts e2.render Object.new, {:title=>"this is title", :subtitle=>"this is subtitle", :content=>"this is content"} # some html
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment