Keine Beschreibung http://j1x-huginn.herokuapp.com

liquid_interpolatable.rb 794B

1234567891011121314151617181920212223242526272829303132
  1. module LiquidInterpolatable
  2. extend ActiveSupport::Concern
  3. def interpolate_options(options, payload)
  4. duped_options = options.dup.tap do |duped_options|
  5. duped_options.each_pair do |key, value|
  6. if value.class == String
  7. duped_options[key] = Liquid::Template.parse(value).render(payload)
  8. else
  9. duped_options[key] = value
  10. end
  11. end
  12. end
  13. duped_options
  14. end
  15. def interpolate_string(string, payload)
  16. Liquid::Template.parse(string).render(payload)
  17. end
  18. require 'uri'
  19. # Percent encoding for URI conforming to RFC 3986.
  20. # Ref: http://tools.ietf.org/html/rfc3986#page-12
  21. module Huginn
  22. def uri_escape(string)
  23. CGI::escape string
  24. end
  25. end
  26. Liquid::Template.register_filter(LiquidInterpolatable::Huginn)
  27. end