Class: RunTag
- Inherits:
-
Liquid::Tag
- Object
- Liquid::Tag
- RunTag
- Defined in:
- lib/jekyll_run.rb
Overview
Jekyll tag plugin that executes a program and returns the output from STDOUT. Because the output includes the command that was executed, and is contains unselectable span tags, this plugin is intended to be embedded within a pre tag. Executes a program and returns the output from STDOUT.
Instance Method Summary collapse
-
#initialize(tag_name, command_line, tokens) ⇒ void
constructor
Constructor.
-
#render(_context) ⇒ String
Method prescribed by the Jekyll plugin lifecycle.
Constructor Details
#initialize(tag_name, command_line, tokens) ⇒ void
Constructor.
18 19 20 21 22 23 |
# File 'lib/jekyll_run.rb', line 18 def initialize(tag_name, command_line, tokens) super @command = command_line @command = "" if @command.nil? || @command.empty? @logger = PluginMetaLogger.instance.new_logger(self, PluginMetaLogger.instance.config) end |
Instance Method Details
#render(_context) ⇒ String
Method prescribed by the Jekyll plugin lifecycle.
27 28 29 30 31 |
# File 'lib/jekyll_run.rb', line 27 def render(_context) @logger.debug "Running #{@command}" output = `#{@command}`.rstrip "<span class='unselectable'>$ </span>#{@command}\n<span class='unselectable'>#{output}</span>" end |