class RDoc::ERBIO
ERB
的一个子类,直接写入 IO
。感谢 Aaron Patterson 和 Masatoshi SEKI 的贡献。
使用方法
erbio = RDoc::ERBIO.new '<%= "hello world" %>', nil, nil File.open 'hello.txt', 'w' do |io| erbio.result binding end
请注意,绑定必须包含您希望输出的 io。
公共类方法
源代码
# File lib/rdoc/erbio.rb, line 23 def initialize str, trim_mode: nil, eoutvar: 'io' super(str, trim_mode: trim_mode, eoutvar: eoutvar) end
eoutvar
默认为 'io',否则与 ERB 的 initialize 方法相同
调用超类方法
ERB::new
公共实例方法
源代码
# File lib/rdoc/erbio.rb, line 30 def set_eoutvar compiler, io_variable compiler.put_cmd = "#{io_variable}.write" compiler.insert_cmd = "#{io_variable}.write" compiler.pre_cmd = [] compiler.post_cmd = [] end
指示 compiler
如何写入 io_variable