liquid4-rails5 0.1.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (119) hide show
  1. checksums.yaml +7 -0
  2. data/.coveralls.yml +2 -0
  3. data/.gitignore +24 -0
  4. data/.rspec +1 -0
  5. data/.ruby-version +1 -0
  6. data/.travis.yml +22 -0
  7. data/CHANGELOG.md +36 -0
  8. data/Gemfile +12 -0
  9. data/Guardfile +33 -0
  10. data/LICENSE.txt +22 -0
  11. data/README.md +156 -0
  12. data/Rakefile +37 -0
  13. data/gemfiles/rails_32.gemfile +11 -0
  14. data/gemfiles/rails_40.gemfile +11 -0
  15. data/gemfiles/rails_41.gemfile +11 -0
  16. data/gemfiles/rails_42.gemfile +11 -0
  17. data/lib/liquid-rails/drops/collection_drop.rb +91 -0
  18. data/lib/liquid-rails/drops/drop.rb +130 -0
  19. data/lib/liquid-rails/drops/droppable.rb +22 -0
  20. data/lib/liquid-rails/file_system.rb +16 -0
  21. data/lib/liquid-rails/filters/asset_tag_filter.rb +23 -0
  22. data/lib/liquid-rails/filters/asset_url_filter.rb +35 -0
  23. data/lib/liquid-rails/filters/date_filter.rb +17 -0
  24. data/lib/liquid-rails/filters/google_static_map_url_filter.rb +30 -0
  25. data/lib/liquid-rails/filters/misc_filter.rb +29 -0
  26. data/lib/liquid-rails/filters/number_filter.rb +22 -0
  27. data/lib/liquid-rails/filters/paginate_filter.rb +59 -0
  28. data/lib/liquid-rails/filters/sanitize_filter.rb +17 -0
  29. data/lib/liquid-rails/filters/text_filter.rb +44 -0
  30. data/lib/liquid-rails/filters/translate_filter.rb +14 -0
  31. data/lib/liquid-rails/filters/url_filter.rb +24 -0
  32. data/lib/liquid-rails/liquid_monkey_patch.rb +106 -0
  33. data/lib/liquid-rails/matchers.rb +5 -0
  34. data/lib/liquid-rails/railtie.rb +26 -0
  35. data/lib/liquid-rails/rspec/drop_example_group.rb +38 -0
  36. data/lib/liquid-rails/rspec/drop_matchers.rb +165 -0
  37. data/lib/liquid-rails/rspec/filter_example_group.rb +24 -0
  38. data/lib/liquid-rails/rspec/tag_example_group.rb +24 -0
  39. data/lib/liquid-rails/rspec/view_controller_context.rb +45 -0
  40. data/lib/liquid-rails/tags/content_for_tag.rb +77 -0
  41. data/lib/liquid-rails/tags/csrf_meta_tags.rb +11 -0
  42. data/lib/liquid-rails/tags/google_analytics_tag.rb +40 -0
  43. data/lib/liquid-rails/tags/javascript_tag.rb +22 -0
  44. data/lib/liquid-rails/tags/paginate_tag.rb +118 -0
  45. data/lib/liquid-rails/template_handler.rb +44 -0
  46. data/lib/liquid-rails/version.rb +5 -0
  47. data/lib/liquid-rails.rb +24 -0
  48. data/liquid-rails.gemspec +26 -0
  49. data/spec/dummy/README.rdoc +28 -0
  50. data/spec/dummy/Rakefile +6 -0
  51. data/spec/dummy/app/assets/images/.keep +0 -0
  52. data/spec/dummy/app/assets/javascripts/application.js +13 -0
  53. data/spec/dummy/app/assets/stylesheets/application.css +13 -0
  54. data/spec/dummy/app/controllers/application_controller.rb +5 -0
  55. data/spec/dummy/app/controllers/concerns/.keep +0 -0
  56. data/spec/dummy/app/controllers/foospace/bar_controller.rb +5 -0
  57. data/spec/dummy/app/controllers/home_controller.rb +28 -0
  58. data/spec/dummy/app/controllers/pages_controller.rb +16 -0
  59. data/spec/dummy/app/helpers/application_helper.rb +5 -0
  60. data/spec/dummy/app/mailers/.keep +0 -0
  61. data/spec/dummy/app/models/.keep +0 -0
  62. data/spec/dummy/app/models/concerns/.keep +0 -0
  63. data/spec/dummy/app/views/foospace/bar/_partial.liquid +1 -0
  64. data/spec/dummy/app/views/foospace/bar/index_partial.liquid +3 -0
  65. data/spec/dummy/app/views/home/_html_liquid_partial.liquid +1 -0
  66. data/spec/dummy/app/views/home/_partial.liquid +1 -0
  67. data/spec/dummy/app/views/home/erb_with_html_liquid_partial.erb +1 -0
  68. data/spec/dummy/app/views/home/index.liquid +1 -0
  69. data/spec/dummy/app/views/home/index_partial.liquid +4 -0
  70. data/spec/dummy/app/views/home/index_partial_with_full_path.liquid +4 -0
  71. data/spec/dummy/app/views/home/index_with_filter.liquid +2 -0
  72. data/spec/dummy/app/views/home/index_with_layout.liquid +1 -0
  73. data/spec/dummy/app/views/layouts/application.liquid +2 -0
  74. data/spec/dummy/app/views/pages/index_without_filter.liquid +2 -0
  75. data/spec/dummy/app/views/shared/_partial.liquid +1 -0
  76. data/spec/dummy/bin/bundle +3 -0
  77. data/spec/dummy/bin/rails +4 -0
  78. data/spec/dummy/bin/rake +4 -0
  79. data/spec/dummy/config/application.rb +25 -0
  80. data/spec/dummy/config/boot.rb +5 -0
  81. data/spec/dummy/config/environment.rb +5 -0
  82. data/spec/dummy/config/environments/development.rb +29 -0
  83. data/spec/dummy/config/environments/production.rb +80 -0
  84. data/spec/dummy/config/environments/test.rb +36 -0
  85. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  86. data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  87. data/spec/dummy/config/initializers/inflections.rb +16 -0
  88. data/spec/dummy/config/initializers/mime_types.rb +5 -0
  89. data/spec/dummy/config/initializers/secret_token.rb +17 -0
  90. data/spec/dummy/config/initializers/session_store.rb +3 -0
  91. data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
  92. data/spec/dummy/config/locales/en.yml +5 -0
  93. data/spec/dummy/config/locales/km.yml +5 -0
  94. data/spec/dummy/config/routes.rb +14 -0
  95. data/spec/dummy/config.ru +4 -0
  96. data/spec/dummy/lib/assets/.keep +0 -0
  97. data/spec/dummy/log/.keep +0 -0
  98. data/spec/dummy/public/404.html +58 -0
  99. data/spec/dummy/public/422.html +58 -0
  100. data/spec/dummy/public/500.html +57 -0
  101. data/spec/dummy/public/favicon.ico +0 -0
  102. data/spec/fixtures/poro.rb +58 -0
  103. data/spec/lib/liquid-rails/drops/drop_spec.rb +119 -0
  104. data/spec/lib/liquid-rails/filters/asset_tag_filter_spec.rb +22 -0
  105. data/spec/lib/liquid-rails/filters/asset_url_filter_spec.rb +34 -0
  106. data/spec/lib/liquid-rails/filters/google_static_map_url_filter_spec.rb +23 -0
  107. data/spec/lib/liquid-rails/filters/misc_filter_spec.rb +26 -0
  108. data/spec/lib/liquid-rails/filters/translate_filter_spec.rb +29 -0
  109. data/spec/lib/liquid-rails/railtie_spec.rb +9 -0
  110. data/spec/lib/liquid-rails/rspec/drop_matchers_spec.rb +34 -0
  111. data/spec/lib/liquid-rails/tags/content_for_tag_spec.rb +33 -0
  112. data/spec/lib/liquid-rails/tags/csrf_meta_tag_spec.rb +25 -0
  113. data/spec/lib/liquid-rails/tags/google_analtyics_tag_spec.rb +28 -0
  114. data/spec/lib/liquid-rails/tags/javascript_tag_spec.rb +14 -0
  115. data/spec/lib/liquid-rails/tags/paginate_tag_spec.rb +160 -0
  116. data/spec/lib/liquid-rails/template_handler_spec.rb +67 -0
  117. data/spec/spec_helper.rb +42 -0
  118. data/spec/support/delegate_matcher.rb +60 -0
  119. metadata +274 -0
@@ -0,0 +1,24 @@
1
+ module Liquid
2
+ module Rails
3
+ module Rspec
4
+ module TagExampleGroup
5
+ extend ActiveSupport::Concern
6
+ include Liquid::Rails::Rspec::ViewControllerContext
7
+
8
+ included do
9
+ metadata[:type] = :tag
10
+
11
+ before(:all) { setup_view_and_controller }
12
+ end
13
+ end
14
+ end
15
+ end
16
+ end
17
+
18
+ RSpec.configure do |config|
19
+ if RSpec::Core::Version::STRING.starts_with?('3')
20
+ config.include Liquid::Rails::Rspec::TagExampleGroup, type: :tag, file_path: %r(spec/tags)
21
+ else
22
+ config.include Liquid::Rails::Rspec::TagExampleGroup, type: :tag, example_group: { file_path: %r{spec/tags} }
23
+ end
24
+ end
@@ -0,0 +1,45 @@
1
+ module Liquid
2
+ module Rails
3
+ module Rspec
4
+ module ViewControllerContext
5
+ extend ActiveSupport::Concern
6
+
7
+ def setup_view_and_controller
8
+ @view = ActionView::Base.new
9
+ @controller = ApplicationController.new
10
+ @request = ActionController::TestRequest.new('PATH_INFO' => '/')
11
+ @response = ActionController::TestResponse.new
12
+ @response.request = @request
13
+ @controller.request = @request
14
+ @controller.response = @response
15
+ @controller.params = {}
16
+ @view.assign_controller(@controller)
17
+ @view.class.send(:include, @controller._helpers)
18
+ @view.class.send(:include, ::Rails.application.routes.url_helpers)
19
+ end
20
+
21
+ def view
22
+ @view
23
+ end
24
+
25
+ def controller
26
+ @controller
27
+ end
28
+
29
+ def context(assigns={})
30
+ @context ||= ::Liquid::Context.new(assigns, {}, { helper: @view, view: @view, controller: @controller })
31
+ end
32
+
33
+ def expect_template_result(template, expected, assigns={})
34
+ # make assigns available inside context
35
+ assigns.each do |key, value|
36
+ context[key] = value
37
+ end
38
+
39
+ actual = Liquid::Template.parse(template).render!(context)
40
+ expect(actual.to_s.strip).to eq(expected.to_s.strip)
41
+ end
42
+ end
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,77 @@
1
+ # It works similar to Rails #content_for.
2
+ # Calling #content_for stores a block of markup in an identifier for later use.
3
+ # In order to access this stored content in other templates or the layout, you would pass the identifier as an argument to content_for.
4
+ #
5
+ # Usage:
6
+ #
7
+ # {% content_for not_authorized %}
8
+ # alert('You are not authorized to do that!');
9
+ # {% endcontent_for %}
10
+ #
11
+ # You can then use content_for :not_authorized anywhere in your templates.
12
+ # {% if current_user.nil? %}
13
+ # {% yield not_authorized %}
14
+ # {% endif %}
15
+
16
+ module Liquid
17
+ module Rails
18
+ class ContentForTag < ::Liquid::Block
19
+ Syntax = /(#{::Liquid::QuotedFragment}+)\s*(flush\s*(true|false))?/
20
+
21
+ def initialize(tag_name, markup, context)
22
+ super
23
+
24
+ if markup =~ Syntax
25
+ @flush = $3
26
+ @identifier = $1.gsub('\'', '')
27
+ else
28
+ raise SyntaxError.new("Syntax Error - Valid syntax: {% content_for [name] %}")
29
+ end
30
+ end
31
+
32
+ def render(context)
33
+ @context = context
34
+ content = super.html_safe
35
+
36
+ if ::Rails::VERSION::MAJOR == 3 && ::Rails::VERSION::MINOR == 2
37
+ if @flush == 'true'
38
+ @context.registers[:view].view_flow.set(@identifier, content) if content
39
+ else
40
+ @context.registers[:view].view_flow.append(@identifier, content) if content
41
+ end
42
+ else
43
+ options = @flush == 'true' ? { flush: true } : {}
44
+ @context.registers[:view].content_for(@identifier, content, options)
45
+ end
46
+ ''
47
+ end
48
+ end
49
+ end
50
+ end
51
+
52
+ module Liquid
53
+ module Rails
54
+ class YieldTag < ::Liquid::Tag
55
+ Syntax = /(#{::Liquid::QuotedFragment}+)/
56
+
57
+ def initialize(tag_name, markup, context)
58
+ super
59
+
60
+ if markup =~ Syntax
61
+ @identifier = $1.gsub('\'', '')
62
+ else
63
+ raise SyntaxError.new("Syntax Error - Valid syntax: {% yield [name] %}")
64
+ end
65
+ end
66
+
67
+ def render(context)
68
+ @context = context
69
+
70
+ @context.registers[:view].content_for(@identifier).try(:html_safe)
71
+ end
72
+ end
73
+ end
74
+ end
75
+
76
+ Liquid::Template.register_tag('content_for', Liquid::Rails::ContentForTag)
77
+ Liquid::Template.register_tag('yield', Liquid::Rails::YieldTag)
@@ -0,0 +1,11 @@
1
+ module Liquid
2
+ module Rails
3
+ class CsrfMetaTags < ::Liquid::Tag
4
+ def render(context)
5
+ context.registers[:view].csrf_meta_tags
6
+ end
7
+ end
8
+ end
9
+ end
10
+
11
+ Liquid::Template.register_tag('csrf_meta_tags', Liquid::Rails::CsrfMetaTags)
@@ -0,0 +1,40 @@
1
+ # Returns a Google Analytics tag.
2
+ #
3
+ # Usage:
4
+ #
5
+ # {% google_analytics_tag 'UA-XXXXX-X' %}
6
+
7
+ module Liquid
8
+ module Rails
9
+ class GoogleAnalyticsTag < ::Liquid::Tag
10
+ Syntax = /(#{::Liquid::QuotedFragment}+)?/
11
+
12
+ def initialize(tag_name, markup, tokens)
13
+ if markup =~ Syntax
14
+ @account_id = $1.gsub('\'', '')
15
+ else
16
+ raise ::Liquid::SyntaxError.new("Syntax Error in 'google_analytics_tag' - Valid syntax: google_analytics_tag <account_id>")
17
+ end
18
+
19
+ super
20
+ end
21
+
22
+ def render(context)
23
+ %{
24
+ <script type="text/javascript">
25
+
26
+ (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
27
+ (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
28
+ m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
29
+ })(window,document,'script','//www.google-analytics.com/analytics.js','ga');
30
+ ga('create', '#{@account_id}', 'auto');
31
+ ga('send', 'pageview');
32
+
33
+ </script>
34
+ }
35
+ end
36
+ end
37
+ end
38
+ end
39
+
40
+ Liquid::Template.register_tag('google_analytics_tag', Liquid::Rails::GoogleAnalyticsTag)
@@ -0,0 +1,22 @@
1
+ # Returns a JavaScript tag with the content inside.
2
+ #
3
+ # Usage:
4
+ #
5
+ # {% javascript_tag %}
6
+ # alert('Hello Liquid Rails!');
7
+ # {% endjavascript_tag %}
8
+
9
+ module Liquid
10
+ module Rails
11
+ class JavascriptTag < ::Liquid::Block
12
+ include ActionView::Helpers::JavaScriptHelper
13
+ include ActionView::Helpers::TagHelper
14
+
15
+ def render(context)
16
+ javascript_tag(super, type: 'text/javascript')
17
+ end
18
+ end
19
+ end
20
+ end
21
+
22
+ Liquid::Template.register_tag('javascript_tag', Liquid::Rails::JavascriptTag)
@@ -0,0 +1,118 @@
1
+ # Paginate a collection
2
+ #
3
+ # Usage:
4
+ #
5
+ # {% paginate listing.photos by 5 %}
6
+ # {% for photo in paginate.collection %}
7
+ # {{ photo.caption }}
8
+ # {% endfor %}
9
+ # {% endpaginate %}
10
+ #
11
+ module Liquid
12
+ module Rails
13
+ class PaginateTag < ::Liquid::Block
14
+ Syntax = /(#{::Liquid::QuotedFragment})\s*(by\s*(\d+))?/
15
+
16
+ def initialize(tag_name, markup, context)
17
+ super
18
+
19
+ if markup =~ Syntax
20
+ @collection_name = $1
21
+ @page_size = if $2
22
+ $3.to_i
23
+ else
24
+ 25
25
+ end
26
+
27
+ @attributes = { 'window_size' => 3 }
28
+ markup.scan(Liquid::TagAttributes) do |key, value|
29
+ @attributes[key] = value
30
+ end
31
+ else
32
+ raise SyntaxError.new("Syntax Error in tag 'paginate' - Valid syntax: paginate [collection] by number")
33
+ end
34
+ end
35
+
36
+ def render(context)
37
+ @context = context
38
+
39
+ context.stack do
40
+ collection = @context[@collection_name].presence || @context.environments[0][@collection_name]
41
+ raise ::Liquid::ArgumentError.new("Cannot paginate collection '#{@collection_name}'. Not found.") if collection.nil?
42
+
43
+ if collection.is_a? Array
44
+ paginated_collection = Kaminari.paginate_array(collection.to_a).page(current_page).per(@page_size)
45
+ elsif collection.respond_to?(:page)
46
+ paginated_collection = collection.page(current_page).per(@page_size)
47
+ end
48
+
49
+ page_count = paginated_collection.total_pages
50
+ pagination = {}
51
+ pagination['collection'] = paginated_collection
52
+ pagination['current_offset'] = (current_page-1) * @page_size
53
+ pagination['current_page'] = current_page
54
+ pagination['page_size'] = @page_size
55
+ pagination['pages'] = page_count
56
+ pagination['items'] = paginated_collection.total_count
57
+ pagination['previous'] = link('&laquo; Previous'.html_safe, current_page-1 ) unless 1 >= current_page
58
+ pagination['next'] = link('Next &raquo;'.html_safe, current_page+1 ) unless page_count < current_page+1
59
+ pagination['parts'] = []
60
+
61
+ hellip_break = false
62
+ if page_count > 1
63
+ 1.upto(page_count) do |page|
64
+
65
+ if current_page == page
66
+ pagination['parts'] << no_link(page)
67
+ elsif page == 1
68
+ pagination['parts'] << link(page, page)
69
+ elsif page == page_count - 1
70
+ pagination['parts'] << link(page, page)
71
+ elsif page <= current_page - window_size or page >= current_page + window_size
72
+ next if hellip_break
73
+ pagination['parts'] << no_link('&hellip;')
74
+ hellip_break = true
75
+ next
76
+ else
77
+ pagination['parts'] << link(page, page)
78
+ end
79
+
80
+ hellip_break = false
81
+ end
82
+ end
83
+ context['paginate'] = pagination
84
+
85
+ super
86
+ end
87
+ end
88
+
89
+ private
90
+
91
+ def current_page
92
+ _current_page = @context.registers[:controller].params[:page]
93
+ _current_page.nil? ? 1 : _current_page.to_i
94
+ end
95
+
96
+ def current_url
97
+ current_url = @context.registers[:controller].request.fullpath.gsub(/page=[0-9]+&?/, '')
98
+ current_url = current_url.slice(0..-2) if current_url.last == '?' || current_url.last == '&'
99
+ current_url
100
+ end
101
+
102
+ def window_size
103
+ @attributes['window_size']
104
+ end
105
+
106
+ def no_link(title)
107
+ { 'title' => title, 'is_link' => false, 'hellip_break' => (title == '&hellip;') }
108
+ end
109
+
110
+ def link(title, page)
111
+ _current_url = %(#{current_url}#{current_url.include?('?') ? '&' : '?'}page=#{page})
112
+ { 'title' => title, 'url' => _current_url, 'is_link' => true }
113
+ end
114
+ end
115
+ end
116
+ end
117
+
118
+ Liquid::Template.register_tag('paginate', Liquid::Rails::PaginateTag)
@@ -0,0 +1,44 @@
1
+ module Liquid
2
+ module Rails
3
+ class TemplateHandler
4
+
5
+ def self.call(template)
6
+ "Liquid::Rails::TemplateHandler.new(self).render(#{template.source.inspect}, local_assigns)"
7
+ end
8
+
9
+ def initialize(view)
10
+ @view = view
11
+ @controller = @view.controller
12
+ @helper = ActionController::Base.helpers
13
+ end
14
+
15
+ def render(template, local_assigns={})
16
+ @view.controller.headers['Content-Type'] ||= 'text/html; charset=utf-8'
17
+
18
+ assigns = if @controller.respond_to?(:liquid_assigns, true)
19
+ @controller.send(:liquid_assigns)
20
+ else
21
+ @view.assigns
22
+ end
23
+ assigns['content_for_layout'] = @view.content_for(:layout) if @view.content_for?(:layout)
24
+ assigns.merge!(local_assigns.stringify_keys)
25
+
26
+ liquid = Liquid::Template.parse(template)
27
+ render_method = (::Rails.env.development? || ::Rails.env.test?) ? :render! : :render
28
+ liquid.send(render_method, assigns, filters: filters, registers: { view: @view, controller: @controller, helper: @helper }).html_safe
29
+ end
30
+
31
+ def filters
32
+ if @controller.respond_to?(:liquid_filters, true)
33
+ @controller.send(:liquid_filters)
34
+ else
35
+ [@controller._helpers]
36
+ end
37
+ end
38
+
39
+ def compilable?
40
+ false
41
+ end
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,5 @@
1
+ module Liquid
2
+ module Rails
3
+ VERSION = '0.1.5'
4
+ end
5
+ end
@@ -0,0 +1,24 @@
1
+ require 'liquid-rails/version'
2
+ require 'liquid'
3
+ require 'liquid-rails/liquid_monkey_patch'
4
+ require 'kaminari'
5
+ require 'active_support/concern'
6
+
7
+ module Liquid
8
+ module Rails
9
+ autoload :TemplateHandler, 'liquid-rails/template_handler'
10
+ autoload :FileSystem, 'liquid-rails/file_system'
11
+
12
+ autoload :Drop, 'liquid-rails/drops/drop'
13
+ autoload :CollectionDrop, 'liquid-rails/drops/collection_drop'
14
+
15
+ def self.setup_drop(base)
16
+ base.class_eval do
17
+ include Liquid::Rails::Droppable
18
+ end
19
+ end
20
+ end
21
+ end
22
+
23
+ require 'liquid-rails/railtie' if defined?(Rails)
24
+ Dir[File.dirname(__FILE__) + '/liquid-rails/{filters,tags,drops}/*.rb'].each { |f| require f }
@@ -0,0 +1,26 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'liquid-rails/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'liquid4-rails5'
8
+ spec.version = Liquid::Rails::VERSION
9
+ spec.authors = ['Viktor Fonic']
10
+ spec.email = ['viktor.fonic@gmail.com']
11
+ spec.summary = %q{Renders liquid templates with layout and partial support}
12
+ spec.description = %q{It allows you to render .liquid templates with layout and partial support. It also provides filters, tags, drops class to be used inside your liquid template.}
13
+ spec.homepage = ''
14
+ spec.license = 'MIT'
15
+ spec.required_ruby_version = '>= 2.0.0'
16
+ spec.required_rubygems_version = '>= 1.8.11'
17
+
18
+ spec.files = `git ls-files -z`.split("\x0")
19
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
20
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
21
+ spec.require_paths = ['lib']
22
+
23
+ spec.add_dependency 'rails', '>= 3.2'
24
+ spec.add_dependency 'liquid', '>= 3.0.0'
25
+ spec.add_dependency 'kaminari', '>= 0.16.1'
26
+ end
@@ -0,0 +1,28 @@
1
+ == README
2
+
3
+ This README would normally document whatever steps are necessary to get the
4
+ application up and running.
5
+
6
+ Things you may want to cover:
7
+
8
+ * Ruby version
9
+
10
+ * System dependencies
11
+
12
+ * Configuration
13
+
14
+ * Database creation
15
+
16
+ * Database initialization
17
+
18
+ * How to run the test suite
19
+
20
+ * Services (job queues, cache servers, search engines, etc.)
21
+
22
+ * Deployment instructions
23
+
24
+ * ...
25
+
26
+
27
+ Please feel free to use a different markup language if you do not plan to run
28
+ <tt>rake doc:app</tt>.
@@ -0,0 +1,6 @@
1
+ # Add your own tasks in files placed in lib/tasks ending in .rake,
2
+ # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
3
+
4
+ require File.expand_path('../config/application', __FILE__)
5
+
6
+ Dummy::Application.load_tasks
File without changes
@@ -0,0 +1,13 @@
1
+ // This is a manifest file that'll be compiled into application.js, which will include all the files
2
+ // listed below.
3
+ //
4
+ // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
5
+ // or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
6
+ //
7
+ // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
8
+ // compiled file.
9
+ //
10
+ // Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details
11
+ // about supported directives.
12
+ //
13
+ //= require_tree .
@@ -0,0 +1,13 @@
1
+ /*
2
+ * This is a manifest file that'll be compiled into application.css, which will include all the files
3
+ * listed below.
4
+ *
5
+ * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
6
+ * or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
7
+ *
8
+ * You're free to add application-wide styles to this file and they'll appear at the top of the
9
+ * compiled file, but it's generally better to create a new file per style scope.
10
+ *
11
+ *= require_self
12
+ *= require_tree .
13
+ */
@@ -0,0 +1,5 @@
1
+ class ApplicationController < ActionController::Base
2
+ # Prevent CSRF attacks by raising an exception.
3
+ # For APIs, you may want to use :null_session instead.
4
+ protect_from_forgery with: :exception
5
+ end
File without changes
@@ -0,0 +1,5 @@
1
+ class Foospace::BarController < ApplicationController
2
+ def index_partial
3
+ render layout: false
4
+ end
5
+ end
@@ -0,0 +1,28 @@
1
+ class HomeController < ApplicationController
2
+ before_filter :set_book
3
+
4
+ def index
5
+ render layout: false
6
+ end
7
+
8
+ def index_with_layout
9
+ end
10
+
11
+ def index_partial
12
+ end
13
+
14
+ def index_partial_with_full_path
15
+ end
16
+
17
+ def index_with_filter
18
+ end
19
+
20
+ def erb_with_html_liquid_partial
21
+ end
22
+
23
+ private
24
+
25
+ def set_book
26
+ @book = { 'name' => 'Liquid on Rails' }
27
+ end
28
+ end
@@ -0,0 +1,16 @@
1
+ class PagesController < ApplicationController
2
+ before_filter :set_book
3
+
4
+ def index_witout_filter
5
+ end
6
+
7
+ private
8
+
9
+ def liquid_filters
10
+ []
11
+ end
12
+
13
+ def set_book
14
+ @book = { 'name' => 'Liquid on Rails' }
15
+ end
16
+ end
@@ -0,0 +1,5 @@
1
+ module ApplicationHelper
2
+ def truncate_it(input, length)
3
+ input[0..length] + '...'
4
+ end
5
+ end
File without changes
File without changes
File without changes
@@ -0,0 +1 @@
1
+ Bar Partial
@@ -0,0 +1,3 @@
1
+ Foospace::BarController
2
+
3
+ {% include 'partial' %}
@@ -0,0 +1 @@
1
+ <p>Partial Content</p>
@@ -0,0 +1 @@
1
+ Home Partial
@@ -0,0 +1 @@
1
+ <%= render 'html_liquid_partial' %>
@@ -0,0 +1 @@
1
+ {{ book.name }}
@@ -0,0 +1,4 @@
1
+ {{ book.name }}
2
+
3
+ {% include 'partial' %}
4
+ {% include 'shared/partial' %}
@@ -0,0 +1,4 @@
1
+ {{ book.name }}
2
+
3
+ {% include 'home/partial' %}
4
+ {% include 'shared/partial' %}
@@ -0,0 +1,2 @@
1
+ {{ book.name }}
2
+ {{ 'This is a long section of text' | truncate_it: 3 }}
@@ -0,0 +1 @@
1
+ {{ book.name }}
@@ -0,0 +1,2 @@
1
+ Application Layout
2
+ {{ content_for_layout }}
@@ -0,0 +1,2 @@
1
+ {{ book.name }}
2
+ {{ 'This is a long section of text' | truncate_it:3 }}
@@ -0,0 +1 @@
1
+ Shared Partial
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
3
+ load Gem.bin_path('bundler', 'bundle')
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+ APP_PATH = File.expand_path('../../config/application', __FILE__)
3
+ require_relative '../config/boot'
4
+ require 'rails/commands'
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+ require_relative '../config/boot'
3
+ require 'rake'
4
+ Rake.application.run