Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated for tag to use sort_by and order_by tags to allow sorting #1

Open
wants to merge 55 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
39e7810
pass a hash as context when parsing
did Aug 19, 2010
6150705
implementation of template inheritance + tests
did Aug 19, 2010
92aad46
clean code
did Aug 19, 2010
a41213c
change find_blocks method visibility + fix bug
did Aug 19, 2010
ba44b85
keep current block in context during parsing
did Aug 24, 2010
dbcc0b1
a bit of refactoring
did Aug 24, 2010
0c1cf77
a bit of refactoring
did Aug 24, 2010
9e35d06
add the name method in block drops
did Aug 25, 2010
f299f8b
context used in the parsing time was not the same instance all the ti…
did Aug 26, 2010
7ce591f
split the end_tag method for InheritedBlock
did Aug 27, 2010
9ec5709
new algorithm for the inheritance module. This one is much more simpl…
did Aug 30, 2010
b03cdc2
current block pushed in a stack during parsing
did Aug 31, 2010
7a06126
Repackage liquid gem for locomotive
Sep 28, 2010
8c2132d
reorganizing gemspec
Sep 28, 2010
3691796
Cleanup Readme and gemspec
Sep 28, 2010
a9345c4
RSpec environment setup
Sep 28, 2010
49e718e
Converting Block, Assign, and Capture to specs
Sep 28, 2010
9ecb9ff
Converting Condition Test
Sep 28, 2010
f0d0cc8
Converting Context Spec
Sep 28, 2010
876972d
Refactoring specs
Sep 28, 2010
ac1a7bd
Converting drop test
Sep 29, 2010
1fdfc2f
Convert error handling spec
Sep 29, 2010
f3be5a6
Convert template inheritance spec
Sep 29, 2010
bb978e0
spec cleanup and reorg
Sep 29, 2010
67062a4
converting filesystem test
Sep 29, 2010
232645a
Converting filter test
Sep 29, 2010
98eacaf
Reorganizing fixtures
Sep 29, 2010
9ddce08
Converting additional tests to specs
Sep 29, 2010
01a1bfc
include tag spec, and cleanup
Sep 29, 2010
57149f9
Converting some additional output specs
Sep 29, 2010
4e40056
reorganize specs
Sep 29, 2010
d0c109c
Remove money_filter
Sep 29, 2010
508d542
Additional spec refactoring
Sep 29, 2010
ec77241
cleaning out template etsts
Sep 29, 2010
31727bc
Converting filter specs
Sep 29, 2010
bcbc997
reorganize filter spec
Sep 29, 2010
f3affdb
Rspec
Sep 29, 2010
6f20154
Adding output and tag specs
Sep 29, 2010
5276a7b
Refactor tag specs
Sep 30, 2010
893a5f9
Adding RSpec to Rakefile
Sep 30, 2010
448ba2f
cleaning test folder
Sep 30, 2010
cd5e7b7
Additional specs and cleanup
Oct 1, 2010
78d5dad
cleanup whitespace
Oct 1, 2010
093fe3e
Adding strainger spec
Oct 1, 2010
ff43af8
Strainer
Oct 1, 2010
3dada41
Fix up filters for Ruby 1.9.2
Oct 1, 2010
bbab7be
Fix context for Ruby 1.9.2
Oct 1, 2010
fd63553
Additional fixes from master
Oct 1, 2010
89985bc
Adding Literal support + Specs
Oct 1, 2010
8b7b27d
Updating history and readme
Oct 1, 2010
1b27b1a
fixing gemspec
Oct 1, 2010
cd7d7e1
Adding release rake task
Oct 1, 2010
eaee027
Reorgnaize specs a bit
Oct 1, 2010
b107cd2
Add pending default content tag / spec
Oct 1, 2010
d61e77f
Updated for tag to use sort_by and order_by tags to allow sorting and…
waynegerard May 24, 2012
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Refactoring specs
Jacques Crocker committed Sep 28, 2010
commit 876972d383e80e1c03136b9a53b53fa00891472f
10 changes: 5 additions & 5 deletions lib/liquid/context.rb
Original file line number Diff line number Diff line change
@@ -97,7 +97,7 @@ def stack(new_scope={},&block)
end
result
end

def clear_instance_assigns
@scopes[0] = {}
end
@@ -172,7 +172,7 @@ def find_variable(key)
end
scope ||= @environments.last || @scopes.last
variable ||= lookup_and_evaluate(scope, key)

variable = variable.to_liquid
variable.context = self if variable.respond_to?(:context=)
return variable
@@ -230,15 +230,15 @@ def variable(markup)

object
end

def lookup_and_evaluate(obj, key)
if (value = obj[key]).is_a?(Proc) && obj.respond_to?(:[]=)
obj[key] = value.call(self)
else
value
end
end

def squash_instance_assigns_with_environments
@scopes.last.each_key do |k|
@environments.each do |env|
@@ -249,6 +249,6 @@ def squash_instance_assigns_with_environments
end
end
end

end
end
81 changes: 0 additions & 81 deletions spec/parsing/block_spec.rb

This file was deleted.

40 changes: 19 additions & 21 deletions spec/rendering/assign_spec.rb
Original file line number Diff line number Diff line change
@@ -1,30 +1,28 @@
require 'spec_helper'

module Liquid
describe "Liquid Rendering" do
describe "Assignment" do
let(:template) do
Liquid::Template.parse(eval(subject))
end
describe "Liquid Rendering" do
describe "Assignment" do
let(:template) do
Liquid::Template.parse(eval(subject))
end

context %|with 'values' => ["foo", "bar", "baz"]| do
let(:render_options) do
{
'values' => ["foo", "bar", "baz"]
}
end
context %|with 'values' => ["foo", "bar", "baz"]| do
let(:render_options) do
{
'values' => ["foo", "bar", "baz"]
}
end

describe %|"{% assign foo = values %}.{{ foo[0] }}."| do
it{ template.render(render_options).should == ".foo." }
end
describe %|"{% assign foo = values %}.{{ foo[0] }}."| do
it{ template.render(render_options).should == ".foo." }
end

describe %|"{% assign foo = values %}.{{ foo[1] }}."| do
it{ template.render(render_options).should == ".bar." }
end
describe %|"{% assign foo = values %}.{{ foo[1] }}."| do
it{ template.render(render_options).should == ".bar." }
end

describe %|"{% assign foo = values %}.{{ foo[2] }}."| do
it{ template.render(render_options).should == ".baz." }
end
describe %|"{% assign foo = values %}.{{ foo[2] }}."| do
it{ template.render(render_options).should == ".baz." }
end
end
end
98 changes: 48 additions & 50 deletions spec/rendering/capture_spec.rb
Original file line number Diff line number Diff line change
@@ -1,61 +1,59 @@
require 'spec_helper'

module Liquid
describe "Liquid Rendering" do
describe "Capture" do

# capturing blocks content in a variable
describe "assigning a capture block" do
let(:template) do
Liquid::Template.parse multiline_string(<<-END_LIQUID)
| {% capture 'var' %}test string{% endcapture %}
| {{var}}
END_LIQUID
end

it "render the captured block" do
template.render.strip.should == "test string"
end
describe "Liquid Rendering" do
describe "Capture" do

# capturing blocks content in a variable
describe "assigning a capture block" do
let(:template) do
Liquid::Template.parse multiline_string(<<-END_LIQUID)
| {% capture 'var' %}test string{% endcapture %}
| {{var}}
END_LIQUID
end

describe "capturing to a variable from outer scope (if existing)" do
let(:template) do
Liquid::Template.parse multiline_string(<<-END_LIQUID)
| {% assign var = '' %}
| {% if true %}
| {% capture var %}first-block-string{% endcapture %}
| {% endif %}
| {% if true %}
| {% capture var %}test-string{% endcapture %}
| {% endif %}
| {{var}}
END_LIQUID
end

it "should render the captured variable" do
template.render.strip.should == "test-string"
end
it "render the captured block" do
template.render.strip.should == "test string"
end
end

describe "capturing to a variable from outer scope (if existing)" do
let(:template) do
Liquid::Template.parse multiline_string(<<-END_LIQUID)
| {% assign var = '' %}
| {% if true %}
| {% capture var %}first-block-string{% endcapture %}
| {% endif %}
| {% if true %}
| {% capture var %}test-string{% endcapture %}
| {% endif %}
| {{var}}
END_LIQUID
end

it "should render the captured variable" do
template.render.strip.should == "test-string"
end
end

describe "assigning from a capture block" do
let(:template) do
Liquid::Template.parse multiline_string(<<-END_LIQUID)
| {% assign first = '' %}
| {% assign second = '' %}
| {% for number in (1..3) %}
| {% capture first %}{{number}}{% endcapture %}
| {% assign second = first %}
| {% endfor %}
| {{ first }}-{{ second }}
END_LIQUID
end

it "should render the captured variable" do
template.render.strip.should == "3-3"
end
describe "assigning from a capture block" do
let(:template) do
Liquid::Template.parse multiline_string(<<-END_LIQUID)
| {% assign first = '' %}
| {% assign second = '' %}
| {% for number in (1..3) %}
| {% capture first %}{{number}}{% endcapture %}
| {% assign second = first %}
| {% endfor %}
| {{ first }}-{{ second }}
END_LIQUID
end

it "should render the captured variable" do
template.render.strip.should == "3-3"
end

end

end
end
end
79 changes: 79 additions & 0 deletions spec/unit/block_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
require 'spec_helper'

describe "Liquid Parsing" do
describe "Block" do

it "should render whitespace properly" do
template = Liquid::Template.parse(" ")
template.root.nodelist.should == [" "]
end

let(:template) do
Liquid::Template.parse(eval(subject))
end

describe %|"{{funk}} "| do
it{ template.root.nodelist.should have(2).nodes }

it "should parse to: Variable,String" do
template.root.nodelist[0].should be_an_instance_of(Liquid::Variable)
template.root.nodelist[1].should be_an_instance_of(String)
end
end

describe %|" {{funk}}"| do
it{ template.root.nodelist.should have(2).nodes }

it "should parse to: String,Variable" do
template.root.nodelist[0].should be_an_instance_of(String)
template.root.nodelist[1].should be_an_instance_of(Liquid::Variable)
end
end

describe %|" {{funk}} "| do
it{ template.root.nodelist.should have(3).nodes }

it "should parse to: String,Variable,String" do
template.root.nodelist[0].should be_an_instance_of(String)
template.root.nodelist[1].should be_an_instance_of(Liquid::Variable)
template.root.nodelist[2].should be_an_instance_of(String)
end
end

describe %|" {{funk}} {{so}} {{brother}} "| do
it{ template.root.nodelist.should have(7).nodes }

it "should parse to: String,Variable,String,Variable,String,Variable,String" do
template.root.nodelist[0].should be_an_instance_of(String)
template.root.nodelist[1].should be_an_instance_of(Liquid::Variable)
template.root.nodelist[2].should be_an_instance_of(String)
template.root.nodelist[3].should be_an_instance_of(Liquid::Variable)
template.root.nodelist[4].should be_an_instance_of(String)
template.root.nodelist[5].should be_an_instance_of(Liquid::Variable)
template.root.nodelist[6].should be_an_instance_of(String)
end
end

describe %|" {% comment %} {% endcomment %} "| do
it{ template.root.nodelist.should have(3).nodes }
it "should parse to: String,Comment,String" do
template.root.nodelist[0].should be_an_instance_of(String)
template.root.nodelist[1].should be_an_instance_of(Liquid::Comment)
template.root.nodelist[2].should be_an_instance_of(String)
end
end

context "when the custom tag 'somethingaweful' is defined" do
before(:each) do
Liquid::Template.register_tag('somethingaweful', Liquid::Block)
end

describe %|"{% somethingaweful %} {% endsomethingaweful %}"| do
it "should parse successfully" do
template.root.nodelist.should have(1).nodes
end
end
end

end
end
Loading