module Webgen::Tag::ExecuteCommand
Executes the given command and returns the standard output. All special HTML characters are optionally escaped.
Constants
- BIT_BUCKET
Public Class Methods
call(tag, body, context)
click to toggle source
Execute the command and return the standard output.
# File lib/webgen/tag/execute_command.rb 16 def self.call(tag, body, context) 17 command = context[:config]['tag.execute_command.command'] 18 output = `#{command} 2> #{BIT_BUCKET}` 19 if $?.exitstatus != 0 20 raise Webgen::RenderError.new("Command '#{command}' has return value != 0: #{output}", 21 "tag.#{tag}", context.dest_node, context.ref_node) 22 end 23 output = CGI::escapeHTML(output) if context[:config]['tag.execute_command.escape_html'] 24 [output, context[:config]['tag.execute_command.process_output']] 25 end