lib/plezi/common/renderer.rb in plezi-0.12.21 vs lib/plezi/common/renderer.rb in plezi-0.12.22
- old
+ new
@@ -60,11 +60,11 @@
def refresh_sass? sass
return true if Plezi.cache_needs_update?(sass)
# return false unless Plezi.allow_cache_update? # no meaningful performance boost.
mt = Plezi.file_mtime(sass)
- Plezi.get_cached(sass).each {|e| return true if File.exists?(e.options[:filename]) && (File.mtime(e.options[:filename]) > mt)} # fn = File.join( e.options[:load_paths][0].root, e.options[:filename])
+ Plezi.get_cached(sass).each {|e| return true if File.exists?(e.options[:filename]) && (File.mtime(e.options[:filename]) > mt)} # fn = File.join( e.options[:load_paths][0].root, e.options[:filename])
false
end
end
end
@@ -74,11 +74,11 @@
@locker = Mutex.new
module_function
# Registers a rendering extention for a specific asset type (js, css, etc').
#
- # type:: the type of
+ # type:: the type of
# extention:: a Symbol or String representing the extention of the file to be rendered. i.e. 'scss', 'sass', 'coffee', etc'
# handler :: a Proc or other object that answers to call(filename, context, &block) and returnes the rendered string. The block accepted by the handler is for chaining rendered actions (allowing for `yield` within templates) and the context is a Binding object which is offered to the rendering (if `binding` handling is supported by the engine).
#
# handlers are expected to manage caching for their data. The {Plezi::Cache} module is available for this task,
# but it should be noted that Plezi might cache data in that same system and conflicts might occure if the final filename isn't used for the caching (including the handler-type extention, i.e. 'coffee', slim' or 'erb').
@@ -114,25 +114,25 @@
# Render Managment
Renderer = ::Plezi::Base::ExtentionManager.new
Renderer.register :erb do |filename, context, &block|
next unless defined? ::ERB
- ( Plezi.cache_needs_update?(filename) ? Plezi.cache_data( filename, ( ERB.new( IO.binread(filename) ) ) ) : (Plezi.get_cached filename) ).result((context) , &block)
+ ( Plezi.cache_needs_update?(filename) ? Plezi.cache_data( filename, ( ERB.new( Plezi::Base::Helpers.try_utf8! IO.binread(filename) ) ) ) : (Plezi.get_cached filename) ).result((context) , &block)
end
Renderer.register :slim do |filename, context, &block|
next unless defined? ::Slim
- ( Plezi.cache_needs_update?(filename) ? Plezi.cache_data( filename, ( Slim::Template.new() { IO.binread filename } ) ) : (Plezi.get_cached filename) ).render(context.receiver, &block)
+ ( Plezi.cache_needs_update?(filename) ? Plezi.cache_data( filename, ( Slim::Template.new() { Plezi::Base::Helpers.try_utf8! IO.binread(filename) } ) ) : (Plezi.get_cached filename) ).render(context.receiver, &block)
end
Renderer.register :haml do |filename, context, &block|
next unless defined? ::Haml
- ( Plezi.cache_needs_update?(filename) ? Plezi.cache_data( filename, ( Haml::Engine.new( IO.binread(filename) ) ) ) : (Plezi.get_cached filename) ).render(context.receiver, &block)
+ ( Plezi.cache_needs_update?(filename) ? Plezi.cache_data( filename, ( Haml::Engine.new( Plezi::Base::Helpers.try_utf8! IO.binread(filename) ) ) ) : (Plezi.get_cached filename) ).render(context.receiver, &block)
end
# JavaScript asset rendering
AssetManager.register :js, :erb, Renderer.review(:erb)
AssetManager.register :js, :coffee do |filename, context, &block|
next unless defined? ::CoffeeScript
- ( Plezi.cache_needs_update?(filename) ? Plezi.cache_data( filename, CoffeeScript.compile(IO.binread filename) ) : (Plezi.get_cached filename) )
+ ( Plezi.cache_needs_update?(filename) ? Plezi.cache_data( filename, CoffeeScript.compile(Plezi::Base::Helpers.try_utf8!(IO.binread(filename))) ) : (Plezi.get_cached filename) )
end
# CSS asset rendering
AssetManager.register :css, :erb, Renderer.review(:erb)
AssetManager.register :css, :scss, ::Plezi::Base::SASSExt