Module: JekyllEvalFilter

Defined in:
lib/evaluate.rb,
lib/jekyll_eval_filter/version.rb

Overview

Sample Jekyll filter.

Constant Summary collapse

VERSION =
'0.1.3'.freeze

Class Attribute Summary collapse

Instance Method Summary collapse

Class Attribute Details

.loggerObject

Returns the value of attribute logger.



6
7
8
# File 'lib/evaluate.rb', line 6

def logger
  @logger
end

Instance Method Details

#evaluate(input_string) ⇒ String

This Jekyll filter evaluates the input string and returns the result. Use it as a calculator or one-line Ruby program evaluator.

Examples:

Use like this:

{{ 'TODO: show typical input' | eval }} => "TODO: show output"

Parameters:

  • input_string (String)

    .

Returns:

  • (String)

    input string and the evaluation result.



17
18
19
20
21
# File 'lib/evaluate.rb', line 17

def evaluate(input_string)
  input_string.strip!
  JekyllEvalFilter.logger.debug { "input_string=#{input_string}" }
  Kernel.eval input_string.strip
end