Sha256: 21682c27505d919633473236fccdda66add8168f7e49547afe898c13d7d8f988

Contents?: true

Size: 939 Bytes

Versions: 13

Compression:

Stored size: 939 Bytes

Contents

module Locomotive
  module Steam
    module Liquid
      module Drops

        class Params < ::Liquid::Drop

          def initialize(params)
            @_params = params.stringify_keys
          end

          def liquid_method_missing(meth)
            Param.new(@_params[meth.to_s])
          end

          def unsafe
            @_params
          end

          def as_json
            @_params.as_json
          end

        end

        class Param < ::Liquid::Drop

          def initialize(param)
            @param = param
          end

          def html_safe
            @param
          end

          def to_liquid
            @param.is_a?(String) ? html_escape(@param) : @param
          end

          def to_s
            to_liquid.to_s
          end

          private

          def html_escape(string)
            string.blank? ? '' : CGI::escapeHTML(string)
          end

        end

      end
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
locomotivecms_steam-1.8.0.alpha2 lib/locomotive/steam/liquid/drops/params.rb
locomotivecms_steam-1.8.0.alpha1 lib/locomotive/steam/liquid/drops/params.rb
locomotivecms_steam-1.7.1 lib/locomotive/steam/liquid/drops/params.rb
locomotivecms_steam-1.7.0 lib/locomotive/steam/liquid/drops/params.rb
locomotivecms_steam-1.6.1 lib/locomotive/steam/liquid/drops/params.rb
locomotivecms_steam-1.6.0 lib/locomotive/steam/liquid/drops/params.rb
locomotivecms_steam-1.6.0.rc1 lib/locomotive/steam/liquid/drops/params.rb
locomotivecms_steam-1.6.0.beta1 lib/locomotive/steam/liquid/drops/params.rb
locomotivecms_steam-1.5.3 lib/locomotive/steam/liquid/drops/params.rb
locomotivecms_steam-1.5.2 lib/locomotive/steam/liquid/drops/params.rb
locomotivecms_steam-1.5.1 lib/locomotive/steam/liquid/drops/params.rb
locomotivecms_steam-1.5.0 lib/locomotive/steam/liquid/drops/params.rb
locomotivecms_steam-1.5.0.rc1 lib/locomotive/steam/liquid/drops/params.rb