Embedded Ruby without Rails
Ruby seems very nice, but I am starting to find the rails class=table concept repulsive. Also, I do not need rails to do what I want *if* embedded ruby remains feasible. It is not clear to me how realistic that is: can I set out that way and expect to get server support? How? Or is the erb limited to a rails framework, and I should just go learn php instead?
November 4th, 2009, 07:33 PM
You should probably learn PHP to be honest, but Ruby is a fine language :P
Originally Posted by mk27
November 4th, 2009, 09:09 PM
ERB is part of Ruby proper. You can use it without any attachment to Rails. For example:
irb(main):001:0> require 'erb'
irb(main):002:0> erb_str = "<%= x %>"
=> "<%= x %>"
irb(main):003:0> template = ERB.new erb_str
=> #<ERB:0x35b394 @safe_level=nil, @src="_erbout = ''; _erbout.concat(( x ).to_s); _erbout", @filename=nil>
irb(main):004:0> x = 42
irb(main):005:0> puts template.result binding
True happiness is not getting what you want, it's wanting what you've already got.