erubis.rb 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. ##
  2. ## $Release: 2.7.0 $
  3. ## copyright(c) 2006-2011 kuwata-lab.com all rights reserved.
  4. ##
  5. ##
  6. ## an implementation of eRuby
  7. ##
  8. ## ex.
  9. ## input = <<'END'
  10. ## <ul>
  11. ## <% for item in @list %>
  12. ## <li><%= item %>
  13. ## <%== item %></li>
  14. ## <% end %>
  15. ## </ul>
  16. ## END
  17. ## list = ['<aaa>', 'b&b', '"ccc"']
  18. ## eruby = Erubis::Eruby.new(input)
  19. ## puts "--- code ---"
  20. ## puts eruby.src
  21. ## puts "--- result ---"
  22. ## context = Erubis::Context.new() # or new(:list=>list)
  23. ## context[:list] = list
  24. ## puts eruby.evaluate(context)
  25. ##
  26. ## result:
  27. ## --- source ---
  28. ## _buf = ''; _buf << '<ul>
  29. ## '; for item in @list
  30. ## _buf << ' <li>'; _buf << ( item ).to_s; _buf << '
  31. ## '; _buf << ' '; _buf << Erubis::XmlHelper.escape_xml( item ); _buf << '</li>
  32. ## '; end
  33. ## _buf << '</ul>
  34. ## ';
  35. ## _buf.to_s
  36. ## --- result ---
  37. ## <ul>
  38. ## <li><aaa>
  39. ## &lt;aaa&gt;</li>
  40. ## <li>b&b
  41. ## b&amp;b</li>
  42. ## <li>"ccc"
  43. ## &quot;ccc&quot;</li>
  44. ## </ul>
  45. ##
  46. module Erubis
  47. VERSION = ('$Release: 2.7.0 $' =~ /([.\d]+)/) && $1
  48. end
  49. require 'erubis/engine'
  50. #require 'erubis/generator'
  51. #require 'erubis/converter'
  52. #require 'erubis/evaluator'
  53. #require 'erubis/error'
  54. #require 'erubis/context'
  55. #requier 'erubis/util'
  56. require 'erubis/helper'
  57. require 'erubis/enhancer'
  58. #require 'erubis/tiny'
  59. require 'erubis/engine/eruby'
  60. #require 'erubis/engine/enhanced' # enhanced eruby engines
  61. #require 'erubis/engine/optimized' # generates optimized ruby code
  62. #require 'erubis/engine/ephp'
  63. #require 'erubis/engine/ec'
  64. #require 'erubis/engine/ejava'
  65. #require 'erubis/engine/escheme'
  66. #require 'erubis/engine/eperl'
  67. #require 'erubis/engine/ejavascript'
  68. require 'erubis/local-setting'