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, …)
How do I “execute” Ruby templates from command line?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You should have everything you need in your ruby/bin directory. On my (WinXP, Ruby 1.8.6) system, I have
ruby/bin/erb.batso
erb your_erb_file.erbshould write the result to STDOUT.(EDIT: windows has erb.bat and just plain “erb”. The .bat file is just a wrapper for erb, which I guess should make the same command work pretty much the same on any OS)
See the prag prog book discussion (starts about half-way down the page).
Note also that Jack Herrington wrote a whole book about code generation that uses Ruby/ERB.