Skip to content

Commit 19f5f44

Browse files
committed
Support Liquid 4 and Rails 5
1 parent 6181b7b commit 19f5f44

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+550
-218
lines changed

.travis.yml

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,11 @@ rvm:
55
env:
66
- CODECLIMATE_REPO_TOKEN=891d362268d07d6ff0f5534f92252b6195f6be8795054d3627643eb6314a8c9e
77
gemfile:
8-
- gemfiles/rails_32.gemfile
9-
- gemfiles/rails_40.gemfile
10-
- gemfiles/rails_41.gemfile
11-
- gemfiles/rails_42.gemfile
8+
- gemfiles/rails_50.gemfile
9+
- gemfiles/rails_51.gemfile
10+
- gemfiles/rails_52.gemfile
1211
notifications:
1312
email: false
14-
matrix:
15-
exclude:
16-
- rvm: 2.2.0
17-
gemfile: gemfiles/rails_32.gemfile
1813
addons:
1914
code_climate:
2015
repo_token: 891d362268d07d6ff0f5534f92252b6195f6be8795054d3627643eb6314a8c9e

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
# Overview
22

3+
## 0.2.0
4+
5+
### Resolved Issues
6+
7+
* Fix `Content-Type` issue
8+
* Support from Liquid v4, Rails v5, and Kaminari v1 and up
9+
* Use `ActionView::Resolver` as Liquid filesystem (lowang, streppa-ent)
10+
311
## 0.1.4
412

513
### Resolved Issues

Gemfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@ source 'https://rubygems.org'
33
# Specify your gem's dependencies in liquid-rails.gemspec
44
gemspec
55

6-
gem 'rails', '~> 4.2.10'
6+
gem 'rails', '~> 5.0.6'
77
gem 'rake', '~> 12.3.0'
88
gem 'rspec-rails', '~> 3.5.2'
99
gem 'guard-rspec', '~> 4.7.3'
1010
gem 'capybara', '~> 2.16.1'
1111
gem 'pry-rails', '~> 0.3.6'
1212
gem 'coveralls', '~> 0.8.21'
1313
gem 'simplecov', '~> 0.14.1'
14+
gem 'sqlite3', '~> 1.3.13'

Rakefile

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ end
99
task default: 'spec:all'
1010

1111
namespace :spec do
12-
%w(rails_42 rails_41 rails_40 rails_32).each do |gemfile|
12+
rails_versions = %w(rails_50 rails_51 rails_52)
13+
rails_versions.each do |gemfile|
1314
desc "Run Tests against #{gemfile}"
1415
task gemfile do
1516
sh "BUNDLE_GEMFILE='gemfiles/#{gemfile}.gemfile' bundle --quiet"
@@ -19,9 +20,9 @@ namespace :spec do
1920

2021
desc "Run Tests against rails versions"
2122
task :all do
22-
%w(rails_42 rails_41 rails_40 rails_32).each do |gemfile|
23+
rails_versions.each do |gemfile|
2324
sh "BUNDLE_GEMFILE='gemfiles/#{gemfile}.gemfile' bundle --quiet"
2425
sh "BUNDLE_GEMFILE='gemfiles/#{gemfile}.gemfile' bundle exec rake spec"
2526
end
2627
end
27-
end
28+
end

gemfiles/rails_42.gemfile

Lines changed: 0 additions & 12 deletions
This file was deleted.
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
source 'https://rubygems.org'
22

3-
gem 'rails', '~> 3.2.21'
3+
gem 'rails', '~> 5.0.6'
44
gem 'rake', '~> 12.3.0'
55
gem 'rspec-rails', '~> 3.5.2'
66
gem 'guard-rspec', '~> 4.7.3'
77
gem 'capybara', '~> 2.16.1'
8-
gem 'test-unit', '~> 3.0'
98
gem 'pry-rails', '~> 0.3.6'
109
gem 'coveralls', '~> 0.8.21'
1110
gem 'simplecov', '~> 0.14.1'
11+
gem 'sqlite3', '~> 1.3.13'
1212

1313
gemspec path: '../'
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
source 'https://rubygems.org'
22

3-
gem 'rails', '~> 4.0.13'
3+
gem 'rails', '~> 5.1.4'
44
gem 'rake', '~> 12.3.0'
55
gem 'rspec-rails', '~> 3.5.2'
66
gem 'guard-rspec', '~> 4.7.3'
77
gem 'capybara', '~> 2.16.1'
88
gem 'pry-rails', '~> 0.3.6'
99
gem 'coveralls', '~> 0.8.21'
1010
gem 'simplecov', '~> 0.14.1'
11+
gem 'sqlite3', '~> 1.3.13'
1112

1213
gemspec path: '../'
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
source 'https://rubygems.org'
22

3-
gem 'rails', '~> 4.1.9'
3+
gem 'rails', '~> 5.2.0.beta2'
44
gem 'rake', '~> 12.3.0'
55
gem 'rspec-rails', '~> 3.5.2'
66
gem 'guard-rspec', '~> 4.7.3'
77
gem 'capybara', '~> 2.16.1'
88
gem 'pry-rails', '~> 0.3.6'
99
gem 'coveralls', '~> 0.8.21'
1010
gem 'simplecov', '~> 0.14.1'
11+
gem 'sqlite3', '~> 1.3.13'
1112

1213
gemspec path: '../'

lib/liquid-rails.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,4 @@ def self.setup_drop(base)
2020
end
2121

2222
require 'liquid-rails/railtie' if defined?(Rails)
23-
Dir[File.dirname(__FILE__) + '/liquid-rails/{filters,tags,drops}/*.rb'].each { |f| require f }
23+
Dir[File.dirname(__FILE__) + '/liquid-rails/{filters,tags,drops}/*.rb'].each { |f| require f }

lib/liquid-rails/file_system.rb

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,36 @@
22

33
module Liquid
44
module Rails
5-
class FileSystem < ::Liquid::LocalFileSystem
6-
def read_template_file(template_path, context)
7-
controller_path = context.registers[:controller].controller_path
5+
class FileSystem
6+
def initialize(view)
7+
@view = view
8+
end
9+
10+
def read_template_file(template_path)
11+
controller_path = view.controller_path
812
template_path = "#{controller_path}/#{template_path}" unless template_path.include?('/')
9-
super
13+
14+
name = template_path.split('/').last
15+
prefix = template_path.split('/')[0...-1].join('/')
16+
17+
result = view.view_paths.find_all(name, prefix, true, lookup_details)
18+
raise FileSystemError, "No such template '#{template_path}'" unless result.present?
19+
20+
result.first.source
21+
end
22+
23+
private
24+
25+
attr_reader :view
26+
27+
def lookup_details
28+
{
29+
locale: [view.locale, :en],
30+
formats: view.formats,
31+
variants: [],
32+
handlers: [:liquid],
33+
versions: []
34+
}
1035
end
1136
end
1237
end

0 commit comments

Comments
 (0)