diff --git a/CHANGELOG b/CHANGELOG index 61f6013..a6a44b1 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,32 +1,32 @@ -Changelog +* Fixed gem install rake task +* Improve Error encapsulation in liquid by maintaining a own set of exceptions instead of relying on ruby build ins -Added If with or / and expressions +* 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 +* Added more tags to standard library -Added include tag ( like partials in rails ) +* Added include tag ( like partials in rails ) -[...] Gazillion of detail improvements +* [...] Gazillion of detail improvements -Added strainers as filter hosts for better security [Tobias Luetke] +* Added strainers as filter hosts for better security [Tobias Luetke] -Fixed that rails integration would call filter with the wrong "self" [Michael Geary] +* Fixed that rails integration would call filter with the wrong "self" [Michael Geary] -Fixed bad error reporting when a filter called a method which doesn't exist. Liquid told you that it couldn't find the -filter which was obviously misleading [Tobias Luetke] +* Fixed bad error reporting when a filter called a method which doesn't exist. Liquid told you that it couldn't find the filter which was obviously misleading [Tobias Luetke] -Removed count helper from standard lib. use size [Tobias Luetke] +* Removed count helper from standard lib. use size [Tobias Luetke] -Fixed bug with string filter parameters failing to tolerate commas in strings. [Paul Hammond] +* 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] +* 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] +* 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 @@ -37,4 +37,4 @@ Added Liquid::Drop. A base class which you can use for exporting proxy objects t t.render('product' => ProductDrop.new ) -Added filter parameters support. Example: {{ date | format_date: "%Y" }} [Paul Hammond] +* Added filter parameters support. Example: {{ date | format_date: "%Y" }} [Paul Hammond] diff --git a/History.txt b/History.txt new file mode 100644 index 0000000..2f1c37f --- /dev/null +++ b/History.txt @@ -0,0 +1,44 @@ +1.9.0 / 2008-03-04 + +* Fixed gem install rake task +* Improve Error encapsulation in liquid by maintaining a own set of exceptions instead of relying on ruby build ins + +Before 1.9.0 + +* 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. + +* Added more tags to standard library + +* Added include tag ( like partials in rails ) + +* [...] Gazillion of detail improvements + +* Added strainers as filter hosts for better security [Tobias Luetke] + +* Fixed that rails integration would call filter with the wrong "self" [Michael Geary] + +* Fixed bad error reporting when a filter called a method which doesn't exist. Liquid told you that it couldn't find the filter which was obviously misleading [Tobias Luetke] + +* Removed count helper from standard lib. use size [Tobias Luetke] + +* 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] + + class ProductDrop < Liquid::Drop + def top_sales + Shop.current.products.find(:all, :order => 'sales', :limit => 10 ) + end + end + t = Liquid::Template.parse( ' {% for product in product.top_sales %} {{ product.name }} {% endfor %} ' ) + t.render('product' => ProductDrop.new ) + + +* Added filter parameters support. Example: {{ date | format_date: "%Y" }} [Paul Hammond] diff --git a/Manifest.txt b/Manifest.txt index 2941b97..4578546 100644 --- a/Manifest.txt +++ b/Manifest.txt @@ -1,7 +1,8 @@ CHANGELOG +History.txt MIT-LICENSE Manifest.txt -README +README.txt Rakefile example/server/example_servlet.rb example/server/liquid_servlet.rb @@ -20,6 +21,7 @@ lib/liquid/errors.rb lib/liquid/extensions.rb lib/liquid/file_system.rb lib/liquid/htmltags.rb +lib/liquid/module_ex.rb lib/liquid/standardfilters.rb lib/liquid/strainer.rb lib/liquid/tag.rb @@ -36,6 +38,7 @@ lib/liquid/tags/unless.rb lib/liquid/template.rb lib/liquid/variable.rb test/block_test.rb +test/condition_test.rb test/context_test.rb test/drop_test.rb test/error_handling_test.rb @@ -47,6 +50,7 @@ test/helper.rb test/html_tag_test.rb test/if_else_test.rb test/include_tag_test.rb +test/module_ex_test.rb test/output_test.rb test/parsing_quirks_test.rb test/regexp_test.rb @@ -56,5 +60,6 @@ test/standard_tag_test.rb test/statements_test.rb test/strainer_test.rb test/template_test.rb +test/test_helper.rb test/unless_else_test.rb test/variable_test.rb diff --git a/README b/README.txt similarity index 100% rename from README rename to README.txt diff --git a/Rakefile b/Rakefile index 1c6df69..a2057ac 100755 --- a/Rakefile +++ b/Rakefile @@ -3,7 +3,7 @@ require 'rubygems' require 'rake' require 'hoe' -PKG_VERSION = "1.7.0" +PKG_VERSION = "1.9.0" PKG_NAME = "liquid" PKG_DESC = "A secure non evaling end user template engine with aesthetic markup." @@ -17,8 +17,8 @@ end Hoe.new(PKG_NAME, PKG_VERSION) do |p| p.rubyforge_name = PKG_NAME p.summary = PKG_DESC - p.description = nil + p.description = PKG_DESC p.author = "Tobias Luetke" p.email = "tobi@leetsoft.com" - p.url = "http://home.leetsoft.com/liquid" + p.url = "http://www.liquidmarkup.org" end \ No newline at end of file diff --git a/lib/liquid/condition.rb b/lib/liquid/condition.rb index b57cfc6..ac30f74 100644 --- a/lib/liquid/condition.rb +++ b/lib/liquid/condition.rb @@ -96,7 +96,7 @@ module Liquid left, right = context[left], context[right] - operation = self.class.operators[op] || raise(ArgumentError.new("Error in tag '#{name}' - Unknown operator #{op}")) + operation = self.class.operators[op] || raise(ArgumentError.new("Unknown operator #{op}")) if operation.respond_to?(:call) operation.call(self, left, right) diff --git a/lib/liquid/context.rb b/lib/liquid/context.rb index abcca59..4cfbb24 100644 --- a/lib/liquid/context.rb +++ b/lib/liquid/context.rb @@ -1,8 +1,5 @@ module Liquid - class ContextError < StandardError - end - # Context keeps the variable stack and resolves variables, as well as keywords # # context['variable'] = 'testing' diff --git a/lib/liquid/errors.rb b/lib/liquid/errors.rb index 4e493b8..0d0343b 100644 --- a/lib/liquid/errors.rb +++ b/lib/liquid/errors.rb @@ -1,7 +1,10 @@ module Liquid - class FilterNotFound < StandardError - end - - class FileSystemError < StandardError - end + class Error < ::StandardError; end + + class ArgumentError < Error; end + class ContextError < Error; end + class FilterNotFound < Error; end + class FileSystemError < Error; end + class StandardError < Error; end + class SyntaxError < Error; end end \ No newline at end of file diff --git a/lib/liquid/strainer.rb b/lib/liquid/strainer.rb index 8106894..7ef5e02 100644 --- a/lib/liquid/strainer.rb +++ b/lib/liquid/strainer.rb @@ -24,7 +24,7 @@ module Liquid end def self.global_filter(filter) - raise StandardError, "Passed filter is not a module" unless filter.is_a?(Module) + raise ArgumentError, "Passed filter is not a module" unless filter.is_a?(Module) @@filters[filter.name] = filter end diff --git a/test/error_handling_test.rb b/test/error_handling_test.rb index 3fbb27f..515f642 100644 --- a/test/error_handling_test.rb +++ b/test/error_handling_test.rb @@ -4,15 +4,15 @@ require File.dirname(__FILE__) + '/helper' class ErrorDrop < Liquid::Drop def standard_error - raise StandardError, 'standard error' + raise Liquid::StandardError, 'standard error' end def argument_error - raise ArgumentError, 'argument error' + raise Liquid::ArgumentError, 'argument error' end def syntax_error - raise SyntaxError, 'syntax error' + raise Liquid::SyntaxError, 'syntax error' end end @@ -59,6 +59,19 @@ class ErrorHandlingTest < Test::Unit::TestCase end + def test_unrecognized_operator + + assert_nothing_raised do + + template = Liquid::Template.parse(' {% if 1 =! 2 %}ok{% endif %} ') + assert_equal ' Liquid error: Unknown operator =! ', template.render + + assert_equal 1, template.errors.size + assert_equal Liquid::ArgumentError, template.errors.first.class + + end + + end end