From 0e3b522fe2caa7700f177913a85360a212930b77 Mon Sep 17 00:00:00 2001 From: Dennis Theisen Date: Mon, 12 Mar 2012 16:38:34 -0400 Subject: [PATCH 1/2] Fix conditions using negative number comparisons --- lib/liquid/context.rb | 4 ++-- test/liquid/condition_test.rb | 5 +++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/liquid/context.rb b/lib/liquid/context.rb index 1075c4e..1d5290a 100644 --- a/lib/liquid/context.rb +++ b/lib/liquid/context.rb @@ -136,11 +136,11 @@ module Liquid $1 when /^"(.*)"$/ # Double quoted strings $1 - when /^(\d+)$/ # Integer and floats + when /^(-?\d+)$/ # Integer and floats $1.to_i when /^\((\S+)\.\.(\S+)\)$/ # Ranges (resolve($1).to_i..resolve($2).to_i) - when /^(\d[\d\.]+)$/ # Floats + when /^(-?\d[\d\.]+)$/ # Floats $1.to_f else variable(key) diff --git a/test/liquid/condition_test.rb b/test/liquid/condition_test.rb index 7dd096e..52a0e03 100644 --- a/test/liquid/condition_test.rb +++ b/test/liquid/condition_test.rb @@ -18,6 +18,11 @@ class ConditionTest < Test::Unit::TestCase assert_evalutes_true '2', '>=', '1' assert_evalutes_true '1', '<=', '2' assert_evalutes_true '1', '<=', '1' + # negative numbers + assert_evalutes_true '1', '>', '-1' + assert_evalutes_true '-1', '<', '1' + assert_evalutes_true '1.0', '>', '-1.0' + assert_evalutes_true '-1.0', '<', '1.0' end def test_default_operators_evalute_false From 1ee342d83b3c32c05de3732246e745f560b3b779 Mon Sep 17 00:00:00 2001 From: Dan Atkinson Date: Wed, 14 Mar 2012 14:58:12 +0000 Subject: [PATCH 2/2] * Seperated 'Howto' into 'How to'. * Added periods to the second list as the first item has them. I guess I'm anally retentive like that. :) --- README.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 982002c..d8e468e 100644 --- a/README.md +++ b/README.md @@ -11,10 +11,10 @@ Liquid is a template engine which was written with very specific requirements: ## Why you should use Liquid * You want to allow your users to edit the appearance of your application but don't want them to run **insecure code on your server**. -* You want to render templates directly from the database -* You like smarty (PHP) style template engines -* You need a template engine which does HTML just as well as emails -* You don't like the markup of your current templating engine +* You want to render templates directly from the database. +* You like smarty (PHP) style template engines. +* You need a template engine which does HTML just as well as emails. +* You don't like the markup of your current templating engine. ## What does it look like? @@ -31,7 +31,7 @@ Liquid is a template engine which was written with very specific requirements: ``` -## Howto use Liquid +## How to use Liquid 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.