mirror of
https://github.com/Shopify/liquid.git
synced 2026-09-12 23:40:45 -07:00
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:
@@ -11,10 +11,10 @@ Liquid is a template engine which was written with very specific requirements:
|
|||||||
## Why you should use Liquid
|
## 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 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 want to render templates directly from the database.
|
||||||
* You like smarty (PHP) style template engines
|
* You like smarty (PHP) style template engines.
|
||||||
* You need a template engine which does HTML just as well as emails
|
* 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 don't like the markup of your current templating engine.
|
||||||
|
|
||||||
## What does it look like?
|
## What does it look like?
|
||||||
|
|
||||||
@@ -31,7 +31,7 @@ Liquid is a template engine which was written with very specific requirements:
|
|||||||
</ul>
|
</ul>
|
||||||
```
|
```
|
||||||
|
|
||||||
## Howto use Liquid
|
## How to use Liquid
|
||||||
|
|
||||||
Liquid supports a very simple API based around the Liquid::Template class.
|
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.
|
For standard use you can just pass it the content of a file and call render with a parameters hash.
|
||||||
|
|||||||
@@ -136,11 +136,11 @@ module Liquid
|
|||||||
$1
|
$1
|
||||||
when /^"(.*)"$/ # Double quoted strings
|
when /^"(.*)"$/ # Double quoted strings
|
||||||
$1
|
$1
|
||||||
when /^(\d+)$/ # Integer and floats
|
when /^(-?\d+)$/ # Integer and floats
|
||||||
$1.to_i
|
$1.to_i
|
||||||
when /^\((\S+)\.\.(\S+)\)$/ # Ranges
|
when /^\((\S+)\.\.(\S+)\)$/ # Ranges
|
||||||
(resolve($1).to_i..resolve($2).to_i)
|
(resolve($1).to_i..resolve($2).to_i)
|
||||||
when /^(\d[\d\.]+)$/ # Floats
|
when /^(-?\d[\d\.]+)$/ # Floats
|
||||||
$1.to_f
|
$1.to_f
|
||||||
else
|
else
|
||||||
variable(key)
|
variable(key)
|
||||||
|
|||||||
@@ -18,6 +18,11 @@ class ConditionTest < Test::Unit::TestCase
|
|||||||
assert_evalutes_true '2', '>=', '1'
|
assert_evalutes_true '2', '>=', '1'
|
||||||
assert_evalutes_true '1', '<=', '2'
|
assert_evalutes_true '1', '<=', '2'
|
||||||
assert_evalutes_true '1', '<=', '1'
|
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
|
end
|
||||||
|
|
||||||
def test_default_operators_evalute_false
|
def test_default_operators_evalute_false
|
||||||
|
|||||||
Reference in New Issue
Block a user