Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

0.1.1

  • Loading branch information...
commit b795c802f8ece4d2bed25a235697a8a3f3fa1de2 1 parent 010e314
@yaroslav yaroslav authored
View
12 Rakefile
@@ -16,18 +16,16 @@ end
namespace :profile do
task :default => [:run]
-
+
desc "Run the liquor profile/perforamce coverage"
task :run do
-
+
ruby "performance/shopify.rb"
-
+
end
-
- desc "Run KCacheGrind"
+
+ desc "Run KCacheGrind"
task :grind => :run do
system "kcachegrind /tmp/liquor.rubyprof_calltreeprinter.txt"
end
end
-
-
View
14 lib/extras/liquid_view.rb
@@ -2,7 +2,7 @@
# and use liquid as an template system for .liquid files
#
# Example
-#
+#
# ActionView::Base::register_template_handler :liquid, LiquidView
class LiquidView
PROTECTED_ASSIGNS = %w( template_root response _session template_class action_name request_origin session template
@@ -10,7 +10,7 @@ class LiquidView
ignore_missing_templates flash _params logger before_filter_chain_aborted headers )
PROTECTED_INSTANCE_VARIABLES = %w( @_request @controller @_first_render @_memoized__pick_template @view_paths
@helpers @assigns_added @template @_render_stack @template_format @assigns )
-
+
def self.call(template)
"LiquidView.new(self).render(template, local_assigns)"
end
@@ -18,10 +18,10 @@ def self.call(template)
def initialize(view)
@view = view
end
-
+
def render(template, local_assigns = nil)
@view.controller.headers["Content-Type"] ||= 'text/html; charset=utf-8'
-
+
# Rails 2.2 Template has source, but not locals
if template.respond_to?(:source) && !template.respond_to?(:locals)
assigns = (@view.instance_variables - PROTECTED_INSTANCE_VARIABLES).inject({}) do |hash, ivar|
@@ -31,15 +31,15 @@ def render(template, local_assigns = nil)
else
assigns = @view.assigns.reject{ |k,v| PROTECTED_ASSIGNS.include?(k) }
end
-
+
source = template.respond_to?(:source) ? template.source : template
local_assigns = (template.respond_to?(:locals) ? template.locals : local_assigns) || {}
-
+
if content_for_layout = @view.instance_variable_get("@content_for_layout")
assigns['content_for_layout'] = content_for_layout
end
assigns.merge!(local_assigns.stringify_keys)
-
+
liquid = Liquid::Template.parse(source)
liquid.render(assigns, :filters => [@view.controller.master_helper_module], :registers => {:action_view => @view, :controller => @view.controller})
end
View
14 lib/extras/liquor_view.rb
@@ -2,7 +2,7 @@
# and use liquor as an template system for .liquor files
#
# Example
-#
+#
# ActionView::Base::register_template_handler :liquor, LiquorView
class LiquorView
PROTECTED_ASSIGNS = %w( template_root response _session template_class action_name request_origin session template
@@ -10,7 +10,7 @@ class LiquorView
ignore_missing_templates flash _params logger before_filter_chain_aborted headers )
PROTECTED_INSTANCE_VARIABLES = %w( @_request @controller @_first_render @_memoized__pick_template @view_paths
@helpers @assigns_added @template @_render_stack @template_format @assigns )
-
+
def self.call(template)
"LiquorView.new(self).render(template, local_assigns)"
end
@@ -18,10 +18,10 @@ def self.call(template)
def initialize(view)
@view = view
end
-
+
def render(template, local_assigns = nil)
@view.controller.headers["Content-Type"] ||= 'text/html; charset=utf-8'
-
+
# Rails 2.2 Template has source, but not locals
if template.respond_to?(:source) && !template.respond_to?(:locals)
assigns = (@view.instance_variables - PROTECTED_INSTANCE_VARIABLES).inject({}) do |hash, ivar|
@@ -31,15 +31,15 @@ def render(template, local_assigns = nil)
else
assigns = @view.assigns.reject{ |k,v| PROTECTED_ASSIGNS.include?(k) }
end
-
+
source = template.respond_to?(:source) ? template.source : template
local_assigns = (template.respond_to?(:locals) ? template.locals : local_assigns) || {}
-
+
if content_for_layout = @view.instance_variable_get("@content_for_layout")
assigns['content_for_layout'] = content_for_layout
end
assigns.merge!(local_assigns.stringify_keys)
-
+
liquor = Liquor::Template.parse(source)
liquor.render(assigns, :filters => [@view.controller.master_helper_module], :registers => {:action_view => @view, :controller => @view.controller})
end
View
2  lib/liquor/version.rb
@@ -1,3 +1,3 @@
module Liquor
- VERSION = "0.1.0"
+ VERSION = "0.1.1"
end
Please sign in to comment.
Something went wrong with that request. Please try again.