liquor 0.1.1 → 0.9.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (176) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +17 -0
  3. data/.rspec +2 -0
  4. data/.travis.yml +3 -9
  5. data/Gemfile +7 -0
  6. data/Guardfile +11 -0
  7. data/MIT-LICENSE +6 -2
  8. data/README.md +4 -122
  9. data/Rakefile +20 -23
  10. data/doc/language-spec.html +768 -0
  11. data/doc/language-spec.md +698 -0
  12. data/lib/liquor.rb +39 -68
  13. data/lib/liquor/ast_tools.rb +28 -0
  14. data/lib/liquor/compiler.rb +110 -0
  15. data/lib/liquor/context.rb +76 -254
  16. data/lib/liquor/diagnostics.rb +151 -0
  17. data/lib/liquor/drop/drop.rb +168 -0
  18. data/lib/liquor/drop/drop_delegation.rb +24 -0
  19. data/lib/liquor/drop/drop_scope.rb +118 -0
  20. data/lib/liquor/drop/dropable.rb +17 -0
  21. data/lib/liquor/emitter.rb +313 -0
  22. data/lib/liquor/extensions/kaminari.rb +14 -0
  23. data/lib/liquor/extensions/pagination.rb +235 -0
  24. data/lib/liquor/extensions/rails.rb +97 -0
  25. data/lib/liquor/extensions/thinking_sphinx.rb +14 -0
  26. data/lib/liquor/extensions/tire.rb +30 -0
  27. data/lib/liquor/external.rb +79 -0
  28. data/lib/liquor/function.rb +94 -0
  29. data/lib/liquor/grammar/lexer.rb +1223 -0
  30. data/lib/liquor/grammar/lexer.rl +297 -0
  31. data/lib/liquor/grammar/parser.racc +288 -0
  32. data/lib/liquor/grammar/parser.rb +885 -0
  33. data/lib/liquor/library.rb +41 -0
  34. data/lib/liquor/manager.rb +146 -0
  35. data/lib/liquor/runtime.rb +167 -0
  36. data/lib/liquor/stdlib/builtin_functions.rb +315 -0
  37. data/lib/liquor/stdlib/builtin_tags.rb +228 -0
  38. data/lib/liquor/stdlib/html_truncater.rb +162 -0
  39. data/lib/liquor/stdlib/partial_tags.rb +76 -0
  40. data/lib/liquor/tag.rb +83 -14
  41. data/lib/liquor/version.rb +1 -1
  42. data/liquor.gemspec +29 -6
  43. data/spec/builtins_spec.rb +264 -0
  44. data/spec/compiler_spec.rb +136 -0
  45. data/spec/context_spec.rb +49 -0
  46. data/spec/drop_delegation_spec.rb +21 -0
  47. data/spec/drop_spec.rb +222 -0
  48. data/spec/errors_spec.rb +40 -0
  49. data/spec/external_spec.rb +207 -0
  50. data/spec/function_spec.rb +80 -0
  51. data/spec/lexer_spec.rb +173 -0
  52. data/spec/library_spec.rb +18 -0
  53. data/spec/manager_spec.rb +84 -0
  54. data/spec/parser_spec.rb +381 -0
  55. data/spec/partials_spec.rb +74 -0
  56. data/spec/runtime_spec.rb +97 -0
  57. data/spec/spec_helper.rb +94 -0
  58. data/spec/tag_spec.rb +7 -0
  59. metadata +216 -173
  60. data/AUTHORS +0 -2
  61. data/CHANGELOG +0 -48
  62. data/Gemfile.lock +0 -91
  63. data/History.txt +0 -44
  64. data/LICENSE +0 -23
  65. data/example/server/example_servlet.rb +0 -37
  66. data/example/server/liquid_servlet.rb +0 -28
  67. data/example/server/liquor_servlet.rb +0 -28
  68. data/example/server/server.rb +0 -12
  69. data/example/server/templates/index.liquid +0 -6
  70. data/example/server/templates/index.liquor +0 -6
  71. data/example/server/templates/products.liquid +0 -45
  72. data/example/server/templates/products.liquor +0 -45
  73. data/init.rb +0 -8
  74. data/lib/extras/liquid_view.rb +0 -51
  75. data/lib/extras/liquor_view.rb +0 -51
  76. data/lib/liquor/block.rb +0 -101
  77. data/lib/liquor/condition.rb +0 -120
  78. data/lib/liquor/document.rb +0 -17
  79. data/lib/liquor/drop.rb +0 -256
  80. data/lib/liquor/errors.rb +0 -11
  81. data/lib/liquor/extensions.rb +0 -72
  82. data/lib/liquor/file_system.rb +0 -62
  83. data/lib/liquor/htmltags.rb +0 -74
  84. data/lib/liquor/module_ex.rb +0 -60
  85. data/lib/liquor/standardfilters.rb +0 -315
  86. data/lib/liquor/strainer.rb +0 -58
  87. data/lib/liquor/tags/assign.rb +0 -33
  88. data/lib/liquor/tags/capture.rb +0 -35
  89. data/lib/liquor/tags/case.rb +0 -83
  90. data/lib/liquor/tags/comment.rb +0 -9
  91. data/lib/liquor/tags/content_for.rb +0 -54
  92. data/lib/liquor/tags/cycle.rb +0 -59
  93. data/lib/liquor/tags/for.rb +0 -136
  94. data/lib/liquor/tags/if.rb +0 -80
  95. data/lib/liquor/tags/ifchanged.rb +0 -20
  96. data/lib/liquor/tags/include.rb +0 -56
  97. data/lib/liquor/tags/unless.rb +0 -33
  98. data/lib/liquor/tags/yield.rb +0 -49
  99. data/lib/liquor/template.rb +0 -181
  100. data/lib/liquor/variable.rb +0 -52
  101. data/performance/shopify.rb +0 -92
  102. data/performance/shopify/comment_form.rb +0 -33
  103. data/performance/shopify/database.rb +0 -45
  104. data/performance/shopify/json_filter.rb +0 -7
  105. data/performance/shopify/liquid.rb +0 -18
  106. data/performance/shopify/liquor.rb +0 -18
  107. data/performance/shopify/money_filter.rb +0 -18
  108. data/performance/shopify/paginate.rb +0 -93
  109. data/performance/shopify/shop_filter.rb +0 -98
  110. data/performance/shopify/tag_filter.rb +0 -25
  111. data/performance/shopify/vision.database.yml +0 -945
  112. data/performance/shopify/weight_filter.rb +0 -11
  113. data/performance/tests/dropify/article.liquid +0 -74
  114. data/performance/tests/dropify/blog.liquid +0 -33
  115. data/performance/tests/dropify/cart.liquid +0 -66
  116. data/performance/tests/dropify/collection.liquid +0 -22
  117. data/performance/tests/dropify/index.liquid +0 -47
  118. data/performance/tests/dropify/page.liquid +0 -8
  119. data/performance/tests/dropify/product.liquid +0 -68
  120. data/performance/tests/dropify/theme.liquid +0 -105
  121. data/performance/tests/ripen/article.liquid +0 -74
  122. data/performance/tests/ripen/blog.liquid +0 -13
  123. data/performance/tests/ripen/cart.liquid +0 -54
  124. data/performance/tests/ripen/collection.liquid +0 -29
  125. data/performance/tests/ripen/index.liquid +0 -32
  126. data/performance/tests/ripen/page.liquid +0 -4
  127. data/performance/tests/ripen/product.liquid +0 -75
  128. data/performance/tests/ripen/theme.liquid +0 -85
  129. data/performance/tests/tribble/404.liquid +0 -56
  130. data/performance/tests/tribble/article.liquid +0 -98
  131. data/performance/tests/tribble/blog.liquid +0 -41
  132. data/performance/tests/tribble/cart.liquid +0 -134
  133. data/performance/tests/tribble/collection.liquid +0 -70
  134. data/performance/tests/tribble/index.liquid +0 -94
  135. data/performance/tests/tribble/page.liquid +0 -56
  136. data/performance/tests/tribble/product.liquid +0 -116
  137. data/performance/tests/tribble/search.liquid +0 -51
  138. data/performance/tests/tribble/theme.liquid +0 -90
  139. data/performance/tests/vogue/article.liquid +0 -66
  140. data/performance/tests/vogue/blog.liquid +0 -32
  141. data/performance/tests/vogue/cart.liquid +0 -58
  142. data/performance/tests/vogue/collection.liquid +0 -19
  143. data/performance/tests/vogue/index.liquid +0 -22
  144. data/performance/tests/vogue/page.liquid +0 -3
  145. data/performance/tests/vogue/product.liquid +0 -62
  146. data/performance/tests/vogue/theme.liquid +0 -122
  147. data/test/assign_test.rb +0 -11
  148. data/test/block_test.rb +0 -58
  149. data/test/capture_test.rb +0 -41
  150. data/test/condition_test.rb +0 -115
  151. data/test/content_for_test.rb +0 -15
  152. data/test/context_test.rb +0 -479
  153. data/test/drop_test.rb +0 -162
  154. data/test/error_handling_test.rb +0 -89
  155. data/test/extra/breakpoint.rb +0 -547
  156. data/test/extra/caller.rb +0 -80
  157. data/test/file_system_test.rb +0 -30
  158. data/test/filter_test.rb +0 -147
  159. data/test/helper.rb +0 -24
  160. data/test/html_tag_test.rb +0 -31
  161. data/test/if_else_test.rb +0 -139
  162. data/test/include_tag_test.rb +0 -129
  163. data/test/module_ex_test.rb +0 -89
  164. data/test/output_test.rb +0 -121
  165. data/test/parsing_quirks_test.rb +0 -54
  166. data/test/regexp_test.rb +0 -45
  167. data/test/security_test.rb +0 -41
  168. data/test/standard_filter_test.rb +0 -170
  169. data/test/standard_tag_test.rb +0 -405
  170. data/test/statements_test.rb +0 -137
  171. data/test/strainer_test.rb +0 -27
  172. data/test/template_test.rb +0 -82
  173. data/test/test_helper.rb +0 -28
  174. data/test/unless_else_test.rb +0 -27
  175. data/test/variable_test.rb +0 -173
  176. data/test/yield_test.rb +0 -24
@@ -1,92 +0,0 @@
1
- # This profiler run simulates Shopify.
2
- # We are looking in the tests directory for liquor files and render them within the designated layout file.
3
- # We will also export a substantial database to liquor which the templates can render values of.
4
- # All this is to make the benchmark as non syntetic as possible. All templates and tests are lifted from
5
- # direct real-world usage and the profiler measures code that looks very similar to the way it looks in
6
- # Shopify which is likely the biggest user of liquor in the world which something to the tune of several
7
- # million Template#render calls a day.
8
-
9
- require 'rubygems'
10
- require 'active_support'
11
- require 'yaml'
12
- require 'digest/md5'
13
- require File.dirname(__FILE__) + '/shopify/liquor'
14
- require File.dirname(__FILE__) + '/shopify/database.rb'
15
-
16
- require "ruby-prof" rescue fail("install ruby-prof extension/gem")
17
-
18
- class ThemeProfiler
19
-
20
- # Load all templates into memory, do this now so that
21
- # we don't profile IO.
22
- def initialize
23
- @tests = Dir[File.dirname(__FILE__) + '/tests/**/*.liquor'].collect do |test|
24
- next if File.basename(test) == 'theme.liquor'
25
-
26
- theme_path = File.dirname(test) + '/theme.liquor'
27
-
28
- [File.read(test), (File.file?(theme_path) ? File.read(theme_path) : nil), test]
29
- end.compact
30
- end
31
-
32
-
33
- def profile
34
- RubyProf.measure_mode = RubyProf::WALL_TIME
35
-
36
- # Dup assigns because will make some changes to them
37
- assigns = Database.tables.dup
38
-
39
- @tests.each do |liquor, layout, template_name|
40
-
41
- # Compute page_tempalte outside of profiler run, uninteresting to profiler
42
- html = nil
43
- page_template = File.basename(template_name, File.extname(template_name))
44
-
45
- # Profile compiling and rendering both
46
- RubyProf.resume { html = compile_and_render(liquor, layout, assigns, page_template) }
47
-
48
- # return the result and the MD5 of the content, this can be used to detect regressions between liquor version
49
- $stdout.puts "* rendered template %s, content: %s" % [template_name, Digest::MD5.hexdigest(html)]
50
-
51
- # Uncomment to dump html files to /tmp so that you can inspect for errors
52
- # File.open("/tmp/#{File.basename(template_name)}.html", "w+") { |fp| fp <<html}
53
- end
54
-
55
- RubyProf.stop
56
- end
57
-
58
- def compile_and_render(template, layout, assigns, page_template)
59
- tmpl = Liquor::Template.new
60
- tmpl.assigns['page_title'] = 'Page title'
61
- tmpl.assigns['template'] = page_template
62
-
63
- content_for_layout = tmpl.parse(template).render(assigns)
64
-
65
- if layout
66
- assigns['content_for_layout'] = content_for_layout
67
- tmpl.parse(layout).render(assigns)
68
- else
69
- content_for_layout
70
- end
71
- end
72
- end
73
-
74
-
75
- profiler = ThemeProfiler.new
76
-
77
- puts 'Running profiler...'
78
-
79
- results = profiler.profile
80
-
81
- puts 'Success'
82
- puts
83
-
84
- [RubyProf::FlatPrinter, RubyProf::GraphPrinter, RubyProf::GraphHtmlPrinter, RubyProf::CallTreePrinter].each do |klass|
85
- filename = (ENV['TMP'] || '/tmp') + (klass.name.include?('Html') ? "/liquor.#{klass.name.downcase}.html" : "/liquor.#{klass.name.downcase}.txt")
86
- filename.gsub!(/:+/, '_')
87
- File.open(filename, "w+") { |fp| klass.new(results).print(fp) }
88
- $stderr.puts "wrote #{klass.name} output to #{filename}"
89
- end
90
-
91
-
92
-
@@ -1,33 +0,0 @@
1
- class CommentForm < Liquor::Block
2
- Syntax = /(#{Liquor::VariableSignature}+)/
3
-
4
- def initialize(tag_name, markup, tokens)
5
- if markup =~ Syntax
6
- @variable_name = $1
7
- @attributes = {}
8
- else
9
- raise SyntaxError.new("Syntax Error in 'comment_form' - Valid syntax: comment_form [article]")
10
- end
11
-
12
- super
13
- end
14
-
15
- def render(context)
16
- article = context[@variable_name]
17
-
18
- context.stack do
19
- context['form'] = {
20
- 'posted_successfully?' => context.registers[:posted_successfully],
21
- 'errors' => context['comment.errors'],
22
- 'author' => context['comment.author'],
23
- 'email' => context['comment.email'],
24
- 'body' => context['comment.body']
25
- }
26
- wrap_in_form(article, render_all(@nodelist, context))
27
- end
28
- end
29
-
30
- def wrap_in_form(article, input)
31
- %Q{<form id="article-#{article.id}-comment-form" class="comment-form" method="post" action="">\n#{input}\n</form>}
32
- end
33
- end
@@ -1,45 +0,0 @@
1
- require 'yaml'
2
- module Database
3
-
4
- # Load the standard vision toolkit database and re-arrage it to be simply exportable
5
- # to liquid as assigns. All this is based on Shopify
6
- def self.tables
7
- @tables ||= begin
8
- db = YAML.load_file(File.dirname(__FILE__) + '/vision.database.yml')
9
-
10
- # From vision source
11
- db['products'].each do |product|
12
- collections = db['collections'].find_all do |collection|
13
- collection['products'].any? { |p| p['id'].to_i == product['id'].to_i }
14
- end
15
- product['collections'] = collections
16
- end
17
-
18
- # key the tables by handles, as this is how liquid expects it.
19
- db = db.inject({}) do |assigns, (key, values)|
20
- assigns[key] = values.inject({}) { |h, v| h[v['handle']] = v; h; }
21
- assigns
22
- end
23
-
24
- # Some standard direct accessors so that the specialized templates
25
- # render correctly
26
- db['collection'] = db['collections'].values.first
27
- db['product'] = db['products'].values.first
28
- db['blog'] = db['blogs'].values.first
29
- db['article'] = db['blog']['articles'].first
30
-
31
- db['cart'] = {
32
- 'total_price' => db['line_items'].values.inject(0) { |sum, item| sum += item['line_price'] * item['quantity'] },
33
- 'item_count' => db['line_items'].values.inject(0) { |sum, item| sum += item['quantity'] },
34
- 'items' => db['line_items'].values
35
- }
36
-
37
- db
38
- end
39
- end
40
- end
41
-
42
- if __FILE__ == $0
43
- p Database.tables['collections']['frontpage'].keys
44
- #p Database.tables['blog']['articles']
45
- end
@@ -1,7 +0,0 @@
1
- module JsonFilter
2
-
3
- def json(object)
4
- object.reject {|k,v| k == "collections" }.to_json
5
- end
6
-
7
- end
@@ -1,18 +0,0 @@
1
- require File.dirname(__FILE__) + '/../../lib/liquid'
2
-
3
- require File.dirname(__FILE__) + '/comment_form'
4
- require File.dirname(__FILE__) + '/paginate'
5
- require File.dirname(__FILE__) + '/json_filter'
6
- require File.dirname(__FILE__) + '/money_filter'
7
- require File.dirname(__FILE__) + '/shop_filter'
8
- require File.dirname(__FILE__) + '/tag_filter'
9
- require File.dirname(__FILE__) + '/weight_filter'
10
-
11
- Liquid::Template.register_tag 'paginate', Paginate
12
- Liquid::Template.register_tag 'form', CommentForm
13
-
14
- Liquid::Template.register_filter JsonFilter
15
- Liquid::Template.register_filter MoneyFilter
16
- Liquid::Template.register_filter WeightFilter
17
- Liquid::Template.register_filter ShopFilter
18
- Liquid::Template.register_filter TagFilter
@@ -1,18 +0,0 @@
1
- require File.dirname(__FILE__) + '/../../lib/liquor'
2
-
3
- require File.dirname(__FILE__) + '/comment_form'
4
- require File.dirname(__FILE__) + '/paginate'
5
- require File.dirname(__FILE__) + '/json_filter'
6
- require File.dirname(__FILE__) + '/money_filter'
7
- require File.dirname(__FILE__) + '/shop_filter'
8
- require File.dirname(__FILE__) + '/tag_filter'
9
- require File.dirname(__FILE__) + '/weight_filter'
10
-
11
- Liquor::Template.register_tag 'paginate', Paginate
12
- Liquor::Template.register_tag 'form', CommentForm
13
-
14
- Liquor::Template.register_filter JsonFilter
15
- Liquor::Template.register_filter MoneyFilter
16
- Liquor::Template.register_filter WeightFilter
17
- Liquor::Template.register_filter ShopFilter
18
- Liquor::Template.register_filter TagFilter
@@ -1,18 +0,0 @@
1
- module MoneyFilter
2
-
3
- def money_with_currency(money)
4
- return '' if money.nil?
5
- sprintf("$ %.2f USD", money/100.0)
6
- end
7
-
8
- def money(money)
9
- return '' if money.nil?
10
- sprintf("$ %.2f", money/100.0)
11
- end
12
-
13
- private
14
-
15
- def currency
16
- ShopDrop.new.currency
17
- end
18
- end
@@ -1,93 +0,0 @@
1
- class Paginate < Liquor::Block
2
- Syntax = /(#{Liquor::QuotedFragment})\s*(by\s*(\d+))?/
3
-
4
- def initialize(tag_name, markup, tokens)
5
- @nodelist = []
6
-
7
- if markup =~ Syntax
8
- @collection_name = $1
9
- @page_size = if $2
10
- $3.to_i
11
- else
12
- 20
13
- end
14
-
15
- @attributes = { 'window_size' => 3 }
16
- markup.scan(Liquor::TagAttributes) do |key, value|
17
- @attributes[key] = value
18
- end
19
- else
20
- raise SyntaxError.new("Syntax Error in tag 'paginate' - Valid syntax: paginate [collection] by number")
21
- end
22
-
23
- super
24
- end
25
-
26
- def render(context)
27
- @context = context
28
-
29
- context.stack do
30
- current_page = context['current_page'].to_i
31
-
32
- pagination = {
33
- 'page_size' => @page_size,
34
- 'current_page' => 5,
35
- 'current_offset' => @page_size * 5
36
- }
37
-
38
- context['paginate'] = pagination
39
-
40
- collection_size = context[@collection_name].size
41
-
42
- raise ArgumentError.new("Cannot paginate array '#{@collection_name}'. Not found.") if collection_size.nil?
43
-
44
- page_count = (collection_size.to_f / @page_size.to_f).to_f.ceil + 1
45
-
46
- pagination['items'] = collection_size
47
- pagination['pages'] = page_count -1
48
- pagination['previous'] = link('&laquo; Previous', current_page-1 ) unless 1 >= current_page
49
- pagination['next'] = link('Next &raquo;', current_page+1 ) unless page_count <= current_page+1
50
- pagination['parts'] = []
51
-
52
- hellip_break = false
53
-
54
- if page_count > 2
55
- 1.upto(page_count-1) do |page|
56
-
57
- if current_page == page
58
- pagination['parts'] << no_link(page)
59
- elsif page == 1
60
- pagination['parts'] << link(page, page)
61
- elsif page == page_count -1
62
- pagination['parts'] << link(page, page)
63
- elsif page <= current_page - @attributes['window_size'] or page >= current_page + @attributes['window_size']
64
- next if hellip_break
65
- pagination['parts'] << no_link('&hellip;')
66
- hellip_break = true
67
- next
68
- else
69
- pagination['parts'] << link(page, page)
70
- end
71
-
72
- hellip_break = false
73
- end
74
- end
75
-
76
- render_all(@nodelist, context)
77
- end
78
- end
79
-
80
- private
81
-
82
- def no_link(title)
83
- { 'title' => title, 'is_link' => false}
84
- end
85
-
86
- def link(title, page)
87
- { 'title' => title, 'url' => current_url + "?page=#{page}", 'is_link' => true}
88
- end
89
-
90
- def current_url
91
- "/collections/frontpage"
92
- end
93
- end
@@ -1,98 +0,0 @@
1
- module ShopFilter
2
-
3
- def asset_url(input)
4
- "/files/1/[shop_id]/[shop_id]/assets/#{input}"
5
- end
6
-
7
- def global_asset_url(input)
8
- "/global/#{input}"
9
- end
10
-
11
- def shopify_asset_url(input)
12
- "/shopify/#{input}"
13
- end
14
-
15
- def script_tag(url)
16
- %(<script src="#{url}" type="text/javascript"></script>)
17
- end
18
-
19
- def stylesheet_tag(url, media="all")
20
- %(<link href="#{url}" rel="stylesheet" type="text/css" media="#{media}" />)
21
- end
22
-
23
- def link_to(link, url, title="")
24
- %|<a href="#{url}" title="#{title}">#{link}</a>|
25
- end
26
-
27
- def img_tag(url, alt="")
28
- %|<img src="#{url}" alt="#{alt}" />|
29
- end
30
-
31
- def link_to_vendor(vendor)
32
- if vendor
33
- link_to vendor, url_for_vendor(vendor), vendor
34
- else
35
- 'Unknown Vendor'
36
- end
37
- end
38
-
39
- def link_to_type(type)
40
- if type
41
- link_to type, url_for_type(type), type
42
- else
43
- 'Unknown Vendor'
44
- end
45
- end
46
-
47
- def url_for_vendor(vendor_title)
48
- "/collections/#{vendor_title.to_handle}"
49
- end
50
-
51
- def url_for_type(type_title)
52
- "/collections/#{type_title.to_handle}"
53
- end
54
-
55
- def product_img_url(url, style = 'small')
56
-
57
- unless url =~ /^products\/([\w\-\_]+)\.(\w{2,4})/
58
- raise ArgumentError, 'filter "size" can only be called on product images'
59
- end
60
-
61
- case style
62
- when 'original'
63
- return '/files/shops/random_number/' + url
64
- when 'grande', 'large', 'medium', 'small', 'thumb', 'icon'
65
- "/files/shops/random_number/products/#{$1}_#{style}.#{$2}"
66
- else
67
- raise ArgumentError, 'valid parameters for filter "size" are: original, grande, large, medium, small, thumb and icon '
68
- end
69
- end
70
-
71
- def default_pagination(paginate)
72
-
73
- html = []
74
- html << %(<span class="prev">#{link_to(paginate['previous']['title'], paginate['previous']['url'])}</span>) if paginate['previous']
75
-
76
- for part in paginate['parts']
77
-
78
- if part['is_link']
79
- html << %(<span class="page">#{link_to(part['title'], part['url'])}</span>)
80
- elsif part['title'].to_i == paginate['current_page'].to_i
81
- html << %(<span class="page current">#{part['title']}</span>)
82
- else
83
- html << %(<span class="deco">#{part['title']}</span>)
84
- end
85
-
86
- end
87
-
88
- html << %(<span class="next">#{link_to(paginate['next']['title'], paginate['next']['url'])}</span>) if paginate['next']
89
- html.join(' ')
90
- end
91
-
92
- # Accepts a number, and two words - one for singular, one for plural
93
- # Returns the singular word if input equals 1, otherwise plural
94
- def pluralize(input, singular, plural)
95
- input == 1 ? singular : plural
96
- end
97
-
98
- end
@@ -1,25 +0,0 @@
1
- module TagFilter
2
-
3
- def link_to_tag(label, tag)
4
- "<a title=\"Show tag #{tag}\" href=\"/collections/#{@context['handle']}/#{tag}\">#{label}</a>"
5
- end
6
-
7
- def highlight_active_tag(tag, css_class='active')
8
- if @context['current_tags'].include?(tag)
9
- "<span class=\"#{css_class}\">#{tag}</span>"
10
- else
11
- tag
12
- end
13
- end
14
-
15
- def link_to_add_tag(label, tag)
16
- tags = (@context['current_tags'] + [tag]).uniq
17
- "<a title=\"Show tag #{tag}\" href=\"/collections/#{@context['handle']}/#{tags.join("+")}\">#{label}</a>"
18
- end
19
-
20
- def link_to_remove_tag(label, tag)
21
- tags = (@context['current_tags'] - [tag]).uniq
22
- "<a title=\"Show tag #{tag}\" href=\"/collections/#{@context['handle']}/#{tags.join("+")}\">#{label}</a>"
23
- end
24
-
25
- end