Sha256: ce0e4e8bb5ce12267c3c0b6b71000ea1cf0628d8428de368942d018a0713c186

Contents?: true

Size: 685 Bytes

Versions: 2

Compression:

Stored size: 685 Bytes

Contents

module Octopress
  module VarHelpers
    VAR_SYNTAX = /(#{Liquid::VariableSignature}+)\s*(=|\+=)\s*(.*)\s*/o

    def determine_value(vars, context)
      vars.each do |var|
        rendered = var.render(context)
        return rendered unless rendered.nil?
      end
      nil
    end

    def get_value(vars, context)
      vars = vars.strip.split("||").map do |v|
        Liquid::Variable.new(v.strip)
      end
      value = determine_value(vars, context)
      if value.nil?
        var = vars.last.name
        if var == 'nil'
          nil
        else
          vars.last.name.gsub /^['"]?((?:.)+?)["']?$/, '\1'
        end
      else
        value
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
octopress-3.0.0.alpha2 lib/octopress/liquid_helpers/vars.rb
octopress-3.0.0.alpha1 lib/octopress/liquid_helpers/vars.rb