Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

add a hash example

  • Loading branch information...
commit 5f1c2699ddda9f33a889d5bbfcf1ff28471feed5 1 parent 3111f42
Chris Wanstrath defunkt authored
Showing with 16 additions and 0 deletions.
  1. +16 −0 examples/hash.rb
16 examples/hash.rb
View
@@ -0,0 +1,16 @@
+$LOAD_PATH.unshift File.dirname(__FILE__) + '/../lib'
+require 'mustache'
+
+Mustache.template_file = File.dirname(__FILE__) + '/simple.mustache'
+view = Mustache.new
+
+print "Your name: "
+view[:name] = gets
+view[:value] = value = rand(10_000)
+print "Are you in CA? [y/n] "
+
+if view[:in_ca] = gets.to_s.downcase[0].chr == 'y'
+ view[:taxed_value] = value - (value * 0.4)
+end
+
+puts view.render
Please sign in to comment.
Something went wrong with that request. Please try again.