lib/cobranding/layout.rb in cobranding-1.2.3 vs lib/cobranding/layout.rb in cobranding-1.3.0

- old
+ new

@@ -1,5 +1,8 @@ +# coding: utf-8 +# NOTE this file should be in utf-8 encoding so #evaluate generates a string with +# this encoding. Otherwise on ruby 1.9 it'll be US-ASCII. require 'erb' require 'digest/md5' require 'rest-client' module Cobranding @@ -8,11 +11,11 @@ class Layout QUOTED_RELATIVE_URL = /(<\w+\s((src)|(href))=(['"]))\/(.*?)(\5[^>]*?>)/i UNQUOTED_RELATIVE_URL = /(<\w+\s((src)|(href))=)\/(.*?)(>|(\s[^>]*?>))/i class << self - # Get the layout HTML from a service. The options can be any of the options accepted by SimpleHttpClient + # Get the layout HTML from a service. The options can be any of the options accepted by RestClient # or +:base_url+. Any relative URLs found in the HTML will be expanded to absolute URLs using either the # +:base_url+ option or the +url+ as the base. # # If +:ttl+ is specified in the options, the layout will be cached for that many seconds. # @@ -170,9 +173,11 @@ if src prefix = options[:prefix] if options suffix = options[:suffix] if options suffix = "_for_cobranding" unless prefix or suffix evaluator = Object.new + # "src" is erb code, which contains the code `force_encoding(__ENCODING__)`. + # __ENCODING__ is the current file's encoding (see magic comment above). eval <<-EOS def evaluator.evaluate #{src} end EOS