diff --git a/.gitignore b/.gitignore index 56e80efea..3a17e4003 100644 --- a/.gitignore +++ b/.gitignore @@ -2,5 +2,7 @@ *.gem *.swp pkg +.rvmrc +.bundle/config *.rbc .rvmrc diff --git a/.rspec b/.rspec new file mode 100644 index 000000000..616c43385 --- /dev/null +++ b/.rspec @@ -0,0 +1,2 @@ +--colour +--backtrace diff --git a/Gemfile b/Gemfile new file mode 100644 index 000000000..ab477d461 --- /dev/null +++ b/Gemfile @@ -0,0 +1,10 @@ +source :rubygems + +gem 'rake', '~> 0.9.2' +gem 'rspec', '~> 2.6' #>= 2.0.0.beta.22" +gem 'cucumber', '~> 1.1.9' #'> 0.9.0' +gem 'activesupport' + +platforms :ruby_18 do + gem 'ruby-debug' +end diff --git a/Gemfile.lock b/Gemfile.lock new file mode 100644 index 000000000..83f251f63 --- /dev/null +++ b/Gemfile.lock @@ -0,0 +1,46 @@ +GEM + remote: http://rubygems.org/ + specs: + activesupport (3.2.13) + i18n (= 0.6.1) + multi_json (~> 1.0) + builder (3.0.0) + columnize (0.3.1) + cucumber (1.1.9) + builder (>= 2.1.2) + diff-lcs (>= 1.1.2) + gherkin (~> 2.9.0) + json (>= 1.4.6) + term-ansicolor (>= 1.0.6) + diff-lcs (1.1.3) + gherkin (2.9.3) + json (>= 1.4.6) + i18n (0.6.1) + json (1.7.3) + linecache (0.43) + multi_json (1.6.1) + rake (0.9.2.2) + rspec (2.11.0) + rspec-core (~> 2.11.0) + rspec-expectations (~> 2.11.0) + rspec-mocks (~> 2.11.0) + rspec-core (2.11.1) + rspec-expectations (2.11.1) + diff-lcs (~> 1.1.3) + rspec-mocks (2.11.1) + ruby-debug (0.10.3) + columnize (>= 0.1) + ruby-debug-base (~> 0.10.3.0) + ruby-debug-base (0.10.3) + linecache (>= 0.3) + term-ansicolor (1.0.7) + +PLATFORMS + ruby + +DEPENDENCIES + activesupport + cucumber (~> 1.1.9) + rake (~> 0.9.2) + rspec (~> 2.6) + ruby-debug diff --git a/History.txt b/History.txt new file mode 100644 index 000000000..d97c495c6 --- /dev/null +++ b/History.txt @@ -0,0 +1,57 @@ +2.2.2 + +* Added support for template inheritance {% extends %} + +2.2.1 / 2010-08-23 + +* Added support for literal tags + +2.2.0 / 2010-08-22 + +* Compatible with Ruby 1.8.7, 1.9.1 and 1.9.2-p0 +* Merged some changed made by the community + +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/README.md b/README.md index c3e08e07d..c6e9e6ce8 100644 --- a/README.md +++ b/README.md @@ -32,6 +32,7 @@ Liquid is a template engine which was written with very specific requirements: ``` ## How to use Liquid +>>>>>>> upstream/master Liquid supports a very simple API based around the Liquid::Template class. For standard use you can just pass it the content of a file and call render with a parameters hash. diff --git a/Rakefile b/Rakefile index 862e80f5c..d80d27492 100755 --- a/Rakefile +++ b/Rakefile @@ -1,11 +1,33 @@ #!/usr/bin/env ruby require 'rubygems' +require 'bundler/setup' + require 'rake' require 'rake/testtask' +require 'rspec' +require 'rspec/core/rake_task' require 'rubygems/package_task' -task :default => 'test' +RSpec::Core::RakeTask.new("spec") do |spec| + spec.pattern = "spec/**/*_spec.rb" +end + +desc "Run the Integration Specs (rendering)" +RSpec::Core::RakeTask.new("spec:integration") do |spec| + spec.pattern = "spec/unit/*_spec.rb" +end + +desc "Run the Unit Specs" +RSpec::Core::RakeTask.new("spec:unit") do |spec| + spec.pattern = "spec/unit/*_spec.rb" +end + +desc "Run all the specs without all the verbose spec output" +RSpec::Core::RakeTask.new('spec:progress') do |spec| + spec.rspec_opts = %w(--format progress) + spec.pattern = "spec/**/*_spec.rb" +end Rake::TestTask.new(:test) do |t| t.libs << '.' << 'lib' << 'test' @@ -13,14 +35,22 @@ Rake::TestTask.new(:test) do |t| t.verbose = false end -gemspec = eval(File.read('liquid.gemspec')) +task :default => [:spec, :test] + +gemspec = eval(File.read('locomotive_liquid.gemspec')) + Gem::PackageTask.new(gemspec) do |pkg| pkg.gem_spec = gemspec end desc "Build the gem and release it to rubygems.org" task :release => :gem do - sh "gem push pkg/liquid-#{gemspec.version}.gem" + puts "Tagging #{gemspec.version}..." + system "git tag -a #{gemspec.version} -m 'Tagging #{gemspec.version}'" + puts "Pushing to Github..." + system "git push --tags" + puts "Pushing to rubygems.org..." + system "gem push pkg/#{gemspec.name}-#{gemspec.version}.gem" end namespace :benchmark do @@ -32,7 +62,6 @@ namespace :benchmark do end - namespace :profile do desc "Run the liquid profile/performance coverage" diff --git a/autotest/discover.rb b/autotest/discover.rb new file mode 100644 index 000000000..cd6892ccb --- /dev/null +++ b/autotest/discover.rb @@ -0,0 +1 @@ +Autotest.add_discovery { "rspec2" } diff --git a/example/server/example_servlet.rb b/example/server/example_servlet.rb index e861b7773..5c7e87c50 100644 --- a/example/server/example_servlet.rb +++ b/example/server/example_servlet.rb @@ -2,28 +2,28 @@ module ProductsFilter def price(integer) sprintf("$%.2d USD", integer / 100.0) end - + def prettyprint(text) text.gsub( /\*(.*)\*/, '\1' ) end - + def count(array) array.size end - + def paragraph(p) "
#{p}
" end end class Servlet < LiquidServlet - + def index { 'date' => Time.now } end - - def products - { 'products' => products_list, 'section' => 'Snowboards', 'cool_products' => true} + + def products + { 'products' => products_list, 'section' => 'Snowboards', 'cool_products' => true} end def description @@ -31,11 +31,11 @@ def description end private - + def products_list [{'name' => 'Arbor Draft', 'price' => 39900, 'description' => 'the *arbor draft* is a excellent product' }, {'name' => 'Arbor Element', 'price' => 40000, 'description' => 'the *arbor element* rocks for freestyling'}, {'name' => 'Arbor Diamond', 'price' => 59900, 'description' => 'the *arbor diamond* is a made up product because im obsessed with arbor and have no creativity'}] end - + end diff --git a/example/server/liquid_servlet.rb b/example/server/liquid_servlet.rb index 8f24f0026..b9d5cf6b8 100644 --- a/example/server/liquid_servlet.rb +++ b/example/server/liquid_servlet.rb @@ -7,21 +7,21 @@ def do_GET(req, res) def do_POST(req, res) handle(:post, req, res) end - + private - + def handle(type, req, res) @request, @response = req, res - + @request.path_info =~ /(\w+)$/ - @action = $1 || 'index' - @assigns = send(@action) if respond_to?(@action) + @action = $1 || 'index' + @assigns = send(@action) if respond_to?(@action) @response['Content-Type'] = "text/html" @response.status = 200 - @response.body = Liquid::Template.parse(read_template).render(@assigns, :filters => [ProductsFilter]) + @response.body = Liquid::Template.parse(read_template).render(@assigns, :filters => [ProductsFilter]) end - + def read_template(filename = @action) File.read( File.dirname(__FILE__) + "/templates/#{filename}.liquid" ) end diff --git a/example/server/templates/products.liquid b/example/server/templates/products.liquid index 191d99a9f..e9720c4e9 100644 --- a/example/server/templates/products.liquid +++ b/example/server/templates/products.liquid @@ -1,20 +1,20 @@ - + - +