Merge branch 'master' of git://github.com/Shopify/liquid

* 'master' of git://github.com/Shopify/liquid:
  * 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. :)
  Fix conditions using negative number comparisons
This commit is contained in:
Jeremy Friesen
2012-04-19 10:59:44 -04:00
3 changed files with 12 additions and 7 deletions

View File

@@ -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:
</ul>
```
## 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.

View File

@@ -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)

View File

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