Guest User

Untitled

a guest
May 20th, 2018
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.56 KB | None | 0 0
  1. require 'rubygems'
  2. require 'mustache'
  3.  
  4. class HandleBar < Mustache
  5. def respond_to?(methodname)
  6. methodname = methodname.to_s.split(':').first
  7. super methodname
  8. end
  9.  
  10. def method_missing(methodname, *args)
  11. methodname, args = methodname.to_s.split(/:\s*/)
  12. args = [args].flatten.join.split(/,\s*/)
  13. send methodname, *args
  14. end
  15.  
  16. def wax_me *args
  17. "you've been waxed! #{args.reverse.join(', ')}"
  18. end
  19. end
  20.  
  21. if $0 == __FILE__
  22. h = HandleBar.new
  23. h.template = "Mustache doesn't do arguments you say?\n\n{{wax_me: foo, bar, baz}}"
  24. puts h.to_html
  25. end
Add Comment
Please, Sign In to add comment