Skip to content

Commit

Permalink
merged with success (fix tests) + new name of the gem
Browse files Browse the repository at this point in the history
  • Loading branch information
did committed Sep 23, 2013
2 parents 674840b + 322ecca commit 8e2de42
Show file tree
Hide file tree
Showing 128 changed files with 3,705 additions and 2,179 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ pkg
.bundle/config
*.rbc
.rvmrc
.ruby-version
26 changes: 26 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# How to contribute

## Things we will merge

* Bugfixes
* Performance improvements
* Features which are likely to be useful to the majority of Liquid users

## Things we won't merge

* Code which introduces considerable performance degrations
* Code which touches performance critical parts of Liquid and comes without benchmarks
* Features which are not important for most people (we want to keep the core Liquid code small and tidy)
* Features which can easily be implemented on top of Liquid (for example as a custom filter or custom filesystem)
* Code which comes without tests
* Code which breaks existing tests

## Workflow

* Fork the Liquid repository
* Create a new branch in your fork
* If it makes sense, add tests for your code and run a performance benchmark
* Make sure all tests pass
* Create a pull request
* In the description, ping one of [@boourns](https://github.com/boourns), [@fw42](https://github.com/fw42), [@camilo](https://github.com/camilo), [@dylanahsmith](https://github.com/dylanahsmith), or [@arthurnn](https://github.com/arthurnn) and ask for a code review.

2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
source :rubygems
source 'https://rubygems.org'

gem 'rake', '~> 0.9.2'
gem 'rspec', '~> 2.6' #>= 2.0.0.beta.22"
Expand Down
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
GEM
remote: http://rubygems.org/
remote: https://rubygems.org/
specs:
builder (3.0.0)
columnize (0.3.1)
Expand Down
41 changes: 41 additions & 0 deletions History.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,46 @@
# Liquid Version History

IMPORTANT: Liquid 2.6 is going to be the last version of Liquid which maintains explicit Ruby 1.8 compatability.
The following releases will only be tested against Ruby 1.9 and Ruby 2.0 and are likely to break on Ruby 1.8.

## 2.6.0 / Master branch (not yet released)

* ...
* Add optional strict parsing and warn parsing, see #235 [Tristan Hume, trishume]
* Add I18n syntax error translation, see #241 [Simon Hørup Eskildsen, Sirupsen]
* Make sort filter work on enumerable drops, see #239 [Florian Weingarten, fw42]
* Fix clashing method names in enumerable drops, see #238 [Florian Weingarten, fw42]
* Make map filter work on enumerable drops, see #233 [Florian Weingarten, fw42]
* Fix security issue with map filter, see #230, #232, #234, #237 [Florian Weingarten, fw42]
* Improved whitespace stripping for blank blocks, related to #216 [Florian Weingarten, fw42]
* Bugfix for #106: fix example servlet [gnowoel]
* Bugfix for #97: strip_html filter supports multi-line tags [Jo Liss, joliss]
* Bugfix for #114: strip_html filter supports style tags [James Allardice, jamesallardice]
* Bugfix for #117: 'now' support for date filter in Ruby 1.9 [Notre Dame Webgroup, ndwebgroup]
* Bugfix for #166: truncate filter on UTF-8 strings with Ruby 1.8 [Florian Weingarten, fw42]
* Bugfix for #204: 'raw' parsing bug [Florian Weingarten, fw42]
* Bugfix for #150: 'for' parsing bug [Peter Schröder, phoet]
* Bugfix for #126: Strip CRLF in strip_newline [Peter Schröder, phoet]
* Allow a Liquid::Drop to be passed into Template#render [Daniel Huckstep, darkhelmet]
* Resource limits [Florian Weingarten, fw42]
* Add reverse filter [Jay Strybis, unreal]
* Add utf-8 support
* Use array instead of Hash to keep the registered filters [Tasos Stathopoulos, astathopoulos]
* Cache tokenized partial templates [Tom Burns, boourns]
* Avoid warnings in Ruby 1.9.3 [Marcus Stollsteimer, stomar]
* Better documentation for 'include' tag (closes #163) [Peter Schröder, phoet]
* Use of BigDecimal on filters to have better precision (closes #155) [Arthur Nogueira Neves, arthurnn]


## 2.5.0 / 2013-03-06

* Prevent Object methods from being called on drops
* Avoid symbol injection from liquid
* Added break and continue statements
* Fix filter parser for args without space separators
* Add support for filter keyword arguments


## 2.4.0 / 2012-08-03

* Performance improvements
Expand Down
2 changes: 1 addition & 1 deletion MIT-LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
34 changes: 32 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Liquid template engine

* [Contributing guidelines](CONTRIBUTING.md)
* [Version history](History.md)
* [Liquid documentation from Shopify](http://docs.shopify.com/themes/liquid-basics)
* [Liquid Wiki from Shopify](http://wiki.shopify.com/Liquid)
* [Liquid Wiki at GitHub](https://github.com/Shopify/liquid/wiki)
* [Website](http://liquidmarkup.org/)

## Introduction

Liquid is a template engine which was written with very specific requirements:
Expand Down Expand Up @@ -32,7 +39,6 @@ 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.
Expand All @@ -42,4 +48,28 @@ For standard use you can just pass it the content of a file and call render with
@template.render('name' => 'tobi') # => "hi tobi"
```

[![Build Status](https://secure.travis-ci.org/Shopify/liquid.png)](http://travis-ci.org/Shopify/liquid)
### Error Modes

Setting the error mode of Liquid lets you specify how strictly you want your templates to be interpreted.
Normally the parser is very lax and will accept almost anything without error. Unfortunately this can make
it very hard to debug and can lead to unexpected behaviour.

Liquid also comes with a stricter parser that can be used when editing templates to give better error messages
when templates are invalid. You can enable this new parser like this:

```ruby
Liquid::Template.error_mode = :strict # Raises a SyntaxError when invalid syntax is used
Liquid::Template.error_mode = :warn # Adds errors to template.errors but continues as normal
Liquid::Template.error_mode = :lax # The default mode, accepts almost anything.
```

If you want to set the error mode only on specific templates you can pass `:error_mode` as an option to `parse`:
```ruby
Liquid::Template.parse(source, :error_mode => :strict)
```
This is useful for doing things like enabling strict mode only in the theme editor.

It is recommended that you enable `:strict` or `:warn` mode on new apps to stop invalid templates from being created.
It is also recommended that you use it in the template editors of existing apps to give editors better error messages.

[![Build Status](https://secure.travis-ci.org/Shopify/liquid.png)](http://travis-ci.org/Shopify/liquid)
28 changes: 24 additions & 4 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,31 @@ RSpec::Core::RakeTask.new('spec:progress') do |spec|
spec.pattern = "spec/**/*_spec.rb"
end

Rake::TestTask.new(:test) do |t|
desc 'run test suite with default parser'
Rake::TestTask.new(:base_test) do |t|
t.libs << '.' << 'lib' << 'test'
t.test_files = FileList['test/liquid/**/*_test.rb']
t.verbose = false
end

task :default => [:spec, :test]

gemspec = eval(File.read('locomotive_liquid.gemspec'))
gemspec = eval(File.read('locomotivecms-liquid.gemspec'))

desc 'run test suite with warn error mode'
task :warn_test do
ENV['LIQUID_PARSER_MODE'] = 'warn'
Rake::Task['base_test'].invoke
end

desc 'runs test suite with both strict and lax parsers'
task :test do
ENV['LIQUID_PARSER_MODE'] = 'lax'
Rake::Task['base_test'].invoke
ENV['LIQUID_PARSER_MODE'] = 'strict'
Rake::Task['base_test'].reenable
Rake::Task['base_test'].invoke
end

Gem::PackageTask.new(gemspec) do |pkg|
pkg.gem_spec = gemspec
Expand All @@ -55,11 +71,15 @@ end

namespace :benchmark do

desc "Run the liquid benchmark"
desc "Run the liquid benchmark with lax parsing"
task :run do
ruby "./performance/benchmark.rb"
ruby "./performance/benchmark.rb lax"
end

desc "Run the liquid benchmark with strict parsing"
task :strict do
ruby "./performance/benchmark.rb strict"
end
end

namespace :profile do
Expand Down
10 changes: 5 additions & 5 deletions example/server/example_servlet.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,7 @@ def index
end

def products
{ 'products' => products_list, 'section' => 'Snowboards', 'cool_products' => true}
end

def description
"List of Products ~ This is a list of products with price and description."
{ 'products' => products_list, 'description' => description, 'section' => 'Snowboards', 'cool_products' => true}
end

private
Expand All @@ -38,4 +34,8 @@ def products_list
{'name' => 'Arbor Diamond', 'price' => 59900, 'description' => 'the *arbor diamond* is a made up product because im obsessed with arbor and have no creativity'}]
end

def description
"List of Products ~ This is a list of products with price and description."
end

end
2 changes: 1 addition & 1 deletion example/server/liquid_servlet.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ def handle(type, req, res)
def read_template(filename = @action)
File.read( File.dirname(__FILE__) + "/templates/#{filename}.liquid" )
end
end
end
2 changes: 1 addition & 1 deletion example/server/templates/index.liquid
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
<p>It is {{date}}</p>


<p>Check out the <a href="http://localhost:3000/products">Products</a> screen </p>
<p>Check out the <a href="http://localhost:3000/products">Products</a> screen </p>
28 changes: 14 additions & 14 deletions example/server/templates/products.liquid
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,26 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<meta http-equiv="Content-Language" content="en-us" />
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<meta http-equiv="Content-Language" content="en-us" />

<title>products</title>
<title>products</title>

<meta name="ROBOTS" content="ALL" />
<meta http-equiv="imagetoolbar" content="no" />
<meta name="MSSmartTagsPreventParsing" content="true" />
<meta name="Copyright" content="(c) 2005 Copyright content: Copyright design: Tobias Luetke" />
<!-- (c) Copyright 2005 by Tobias Luetke All Rights Reserved. -->
</head>
<meta name="ROBOTS" content="ALL" />
<meta http-equiv="imagetoolbar" content="no" />
<meta name="MSSmartTagsPreventParsing" content="true" />
<meta name="Copyright" content="(c) 2005 Copyright content: Copyright design: Tobias Luetke" />
<!-- (c) Copyright 2005 by Tobias Luetke All Rights Reserved. -->
</head>

<body>
<body>

<h1>{{ description | split: '~' | first }}</h1>
<h1>{{ description | split: '~' | first }}</h1>

<h2>{{ description | split: '~' | last }}</h2>
<h2>{{ description | split: '~' | last }}</h2>

<h2>There are currently {{products | count}} products in the {{section}} catalog</h2>
<h2>There are currently {{products | count}} products in the {{section}} catalog</h2>

{% if cool_products %}
Cool products :)
Expand Down
2 changes: 1 addition & 1 deletion lib/extras/liquid_view.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,4 @@ def compilable?
false
end

end
end
4 changes: 4 additions & 0 deletions lib/liquid.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ module Liquid
VariableParser = /\[[^\]]+\]|#{VariableSegment}+\??/o
end

require "liquid/version"
require 'liquid/lexer'
require 'liquid/parser'
require 'liquid/i18n'
require 'liquid/drop'
require 'liquid/extensions'
require 'liquid/errors'
Expand Down
Loading

0 comments on commit 8e2de42

Please sign in to comment.