diff --git a/CHANGELOG b/CHANGELOG index 2fb88bc..02920ab 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,5 @@ +* Ruby 1.9.1 bugfixes + * Fix LiquidView for Rails 2.2. Fix local assigns for all versions of Rails * Fixed gem install rake task @@ -5,7 +7,7 @@ * Added If with or / and expressions -* Implemented .to_liquid for all objects which can be passed to liquid like Strings Arrays Hashes Numerics and Booleans. To export new objects to liquid just implement .to_liquid on them and return objects which themselves have .to_liquid methods. +* Implemented .to_liquid for all objects which can be passed to liquid like Strings Arrays Hashes Numerics and Booleans. To export new objects to liquid just implement .to_liquid on them and return objects which themselves have .to_liquid methods. * Added more tags to standard library @@ -24,17 +26,17 @@ * Fixed bug with string filter parameters failing to tolerate commas in strings. [Paul Hammond] * Improved filter parameters. Filter parameters are now context sensitive; Types are resolved according to the rules of the context. Multiple parameters are now separated by the Liquid::ArgumentSeparator: , by default [Paul Hammond] - - {{ 'Typo' | link_to: 'http://typo.leetsoft.com', 'Typo - a modern weblog engine' }} - -* Added Liquid::Drop. A base class which you can use for exporting proxy objects to liquid which can acquire more data when used in liquid. [Tobias Luetke] + {{ 'Typo' | link_to: 'http://typo.leetsoft.com', 'Typo - a modern weblog engine' }} + + +* Added Liquid::Drop. A base class which you can use for exporting proxy objects to liquid which can acquire more data when used in liquid. [Tobias Luetke] class ProductDrop < Liquid::Drop def top_sales Shop.current.products.find(:all, :order => 'sales', :limit => 10 ) end - end + end t = Liquid::Template.parse( ' {% for product in product.top_sales %} {{ product.name }} {% endfor %} ' ) t.render('product' => ProductDrop.new ) diff --git a/lib/liquid/strainer.rb b/lib/liquid/strainer.rb index a857b6c..9fa769b 100644 --- a/lib/liquid/strainer.rb +++ b/lib/liquid/strainer.rb @@ -1,52 +1,51 @@ require 'set' module Liquid - - + parent_object = if defined? BlankObject BlankObject else Object end - # Strainer is the parent class for the filters system. - # New filters are mixed into the strainer class which is then instanciated for each liquid template render run. + # Strainer is the parent class for the filters system. + # New filters are mixed into the strainer class which is then instanciated for each liquid template render run. # - # One of the strainer's responsibilities is to keep malicious method calls out + # One of the strainer's responsibilities is to keep malicious method calls out class Strainer < parent_object #:nodoc: - INTERNAL_METHOD = /^__/ - @@required_methods = Set.new([:__send__, :__id__, :respond_to?, :extend, :methods, :class]) - + INTERNAL_METHOD = /^__/ + @@required_methods = Set.new([:__send__, :respond_to?, :extend, :methods, :class, :object_id]) + @@filters = {} - + def initialize(context) @context = context end - + def self.global_filter(filter) raise ArgumentError, "Passed filter is not a module" unless filter.is_a?(Module) @@filters[filter.name] = filter end - + def self.create(context) strainer = Strainer.new(context) @@filters.each { |k,m| strainer.extend(m) } strainer end - + def respond_to?(method, include_private = false) method_name = method.to_s return false if method_name =~ INTERNAL_METHOD return false if @@required_methods.include?(method_name) super end - - # remove all standard methods from the bucket so circumvent security - # problems - instance_methods.each do |m| - unless @@required_methods.include?(m.to_sym) + + # remove all standard methods from the bucket so circumvent security + # problems + instance_methods.each do |m| + unless @@required_methods.include?(m.to_sym) undef_method m end - end + end end end diff --git a/lib/liquid/variable.rb b/lib/liquid/variable.rb index cf58518..fb39ed7 100644 --- a/lib/liquid/variable.rb +++ b/lib/liquid/variable.rb @@ -21,7 +21,7 @@ module Liquid @name = match[1] if markup.match(/#{FilterSeparator}\s*(.*)/) filters = Regexp.last_match(1).split(/#{FilterSeparator}/) - filters.each do |f| + filters.each do |f| if matches = f.match(/\s*(\w+)/) filtername = matches[1] filterargs = f.scan(/(?:#{FilterArgumentSeparator}|#{ArgumentSeparator})\s*(#{QuotedFragment})/).flatten @@ -34,8 +34,7 @@ module Liquid def render(context) return '' if @name.nil? - output = context[@name] - @filters.inject(output) do |output, filter| + @filters.inject(context[@name]) do |output, filter| filterargs = filter[1].to_a.collect do |a| context[a] end @@ -45,7 +44,6 @@ module Liquid raise FilterNotFound, "Error - filter '#{filter[0]}' in '#{@markup.strip}' could not be found." end end - output end end -end \ No newline at end of file +end diff --git a/liquid.gemspec b/liquid.gemspec index cd57fa6..f7569ef 100644 --- a/liquid.gemspec +++ b/liquid.gemspec @@ -1,10 +1,10 @@ Gem::Specification.new do |s| s.name = %q{liquid} - s.version = "1.9.0" + s.version = "2.0.1" s.specification_version = 2 if s.respond_to? :specification_version= s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= s.authors = ["Tobias Luetke"] - s.date = %q{2008-06-23} + s.date = %q{2009-04-13} s.description = %q{A secure non evaling end user template engine with aesthetic markup.} s.email = %q{tobi@leetsoft.com} s.extra_rdoc_files = ["History.txt", "Manifest.txt", "README.txt"]