I need ERB (Ruby's templating system) for templating of non-HTML files.
(Instead, I want to use it for source files such as .java, .cs, ...)
如何从命令行创建"execute"个Ruby模板?
I need ERB (Ruby's templating system) for templating of non-HTML files.
(Instead, I want to use it for source files such as .java, .cs, ...)
如何从命令行创建"execute"个Ruby模板?
您应该在ruby/bin目录中拥有所需的一切.在我的(WinXP,Ruby 1.8.6)系统上,我有ruby/bin/erb.bat
个
erb.bat [switches] [inputfile]
-x print ruby script
-n print ruby script with line number
-v enable verbose mode
-d set $DEBUG to true
-r [library] load a library
-K [kcode] specify KANJI code-set
-S [safe_level] set $SAFE (0..4)
-T [trim_mode] specify trim_mode (0..2, -)
-P ignore lines which start with "%"
所以erb your_erb_file.erb
应该将结果写入STDOUT.
(编辑:windows有erb.bat,只有简单的"erb"..bat文件只是erb的包装,我想这应该会使同一个命令在任何操作系统上的工作方式几乎相同)
参见prag prog book讨论(从页面的一半开始).
Note also that Jack Herrington wrote a whole book about code generation that uses Ruby/ERB.