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. 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