class Rote::Filters::Exec

Page filter that runs it's body through the specified command, and captures the output. E.g.:

#:exec#python#
  print "Hello, World!"
#:exec#

Although this filter can be used to execute Ruby code, you must bear in mind that this will happen in a separate interpreter process, so no variables or requires from the current environment will be available. If you wish to evaluate Ruby code in your pages, you should use either ERB (evaluated at the beginning of the render), or the Eval filter (evaluated near the end).

Public Class Methods

new(macro_re = MACRO_RE) click to toggle source
Calls superclass method Rote::Filters::MacroFilter::new
   # File lib/rote/filters/exec.rb
30 def initialize(macro_re = MACRO_RE)
31   super([],macro_re)
32 end

Public Instance Methods

macro_exec(cmd,body,raw) click to toggle source
   # File lib/rote/filters/exec.rb
34 def macro_exec(cmd,body,raw)
35   res = IO.popen(cmd, 'w+') do |io|
36     Thread.new { io.write body; io.close_write }
37     io.read
38   end
39 end