Created
September 30, 2013 05:29
-
-
Save coderek/6759673 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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