liquor 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
data/.travis.yml CHANGED
@@ -9,5 +9,4 @@ gemfile:
9
9
  branches:
10
10
  only:
11
11
  - master
12
- - rails
13
12
  - rails32
data/AUTHORS CHANGED
@@ -1,2 +1,2 @@
1
1
  Liquid was originally developed by Tobias Luetke
2
- This fork was developed at Evil Martians by Timothy N. Tsvetkov <timothy.tsvetkov@gmail.com>
2
+ This fork was developed at Evil Martians by Timothy N. Tsvetkov <timothy.tsvetkov@gmail.com>
data/CHANGELOG CHANGED
@@ -1,3 +1,5 @@
1
+ * Rails 3.2+ support [Ivan Evtukhovich, Timothy N. Tsvetkov]
2
+
1
3
  * Forked and added powerful Drops with relations and some new tags. See more in docs [Timothy N. Tsvetkov]
2
4
 
3
5
  * Ruby 1.9.1 bugfixes
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- liquor (0.1.0)
4
+ liquor (0.1.1)
5
5
  rails (~> 3.2.0)
6
6
 
7
7
  GEM
data/LICENSE CHANGED
@@ -1,4 +1,5 @@
1
- Copyright (c) 2012 Ivan Evtukhovich
1
+ Copyright (c) 2005, 2006 Tobias Luetke
2
+ Copyright (c) Timothy N. Tsvetkov
2
3
 
3
4
  MIT License
4
5
 
data/README.md CHANGED
@@ -1,5 +1,4 @@
1
- [https://secure.travis-ci.org/evilmartians/liquor.png](http://travis-ci.org/evilmartians/liquor)
2
-
1
+ <a href="http://travis-ci.org/evilmartians/liquor"><img src="https://secure.travis-ci.org/evilmartians/liquor.png"></a>
3
2
 
4
3
  # Liquor template engine
5
4
 
@@ -21,7 +20,7 @@ Or install it yourself as:
21
20
 
22
21
  ## What does it look like?
23
22
 
24
- ````
23
+ ```html
25
24
  <ul id="products">
26
25
  {% for product in products %}
27
26
  <li>
@@ -32,17 +31,17 @@ Or install it yourself as:
32
31
  </li>
33
32
  {% endfor %}
34
33
  </ul>
35
- ````
34
+ ```
36
35
 
37
36
  ## Howto use Liquor
38
37
 
39
38
  Liquid supports a very simple API based around the Liquor::Template class.
40
39
  For standard use you can just pass it the content of a file and call render with a parameters hash.
41
40
 
42
- ````
41
+ ```ruby
43
42
  @template = Liquid::Template.parse("hi {{name}}") # Parses and compiles the template
44
43
  @template.render( 'name' => '2kan' ) # => "hi 2kan"
45
- ````
44
+ ```
46
45
 
47
46
  ## Differs from Liquid
48
47
 
@@ -54,20 +53,20 @@ Liquor drops are really powerful now. Now you can define access to methods, name
54
53
  #### Attributes
55
54
  To define attributes you need just add line with with attributes you want to provide access to:
56
55
 
57
- ````
56
+ ```ruby
58
57
  class MyDrop < Liquor::Drop
59
58
  self.liquor_attributes << :title << :body
60
59
  end
61
- ````
60
+ ```
62
61
 
63
62
  #### Named Scopes
64
63
  To define access to named scopes (result automatically will be converted to array of liquor drops):
65
64
 
66
- ````
65
+ ```ruby
67
66
  class MyDrop < Liquor::Drop
68
67
  self.liquor_scopes << :recent << :limit << :scoped_to_user
69
68
  end
70
- ````
69
+ ```
71
70
 
72
71
  Named scopes works like filters in templates. Don't worry about passing drop objects in templates as params in real calls they will be converted back to objects and then result will be converted to array of drops.
73
72
 
@@ -94,22 +93,22 @@ Within the context of a layout, yield identifies a section where content from th
94
93
  The simplest way to use this is to have a single yield, into which the entire contents of the view currently being rendered is inserted.
95
94
 
96
95
  In your layout:
97
- ````
96
+ ```erb
98
97
  <title>{% yield title %}</title>
99
98
  <body>{% yield %}</body>
100
- ````
99
+ ```
101
100
 
102
101
  In the view:
103
- ````
102
+ ```erb
104
103
  {% content_for title %} The title {% end_content_for %}
105
104
  The body
106
- ````
105
+ ```
107
106
 
108
107
  Will produce:
109
- ````
108
+ ```html
110
109
  <title>The title</title>
111
110
  <body>The body</body>
112
- ````
111
+ ```
113
112
 
114
113
  ### Filters
115
114
 
data/Rakefile CHANGED
@@ -16,18 +16,16 @@ end
16
16
 
17
17
  namespace :profile do
18
18
  task :default => [:run]
19
-
19
+
20
20
  desc "Run the liquor profile/perforamce coverage"
21
21
  task :run do
22
-
22
+
23
23
  ruby "performance/shopify.rb"
24
-
24
+
25
25
  end
26
-
27
- desc "Run KCacheGrind"
26
+
27
+ desc "Run KCacheGrind"
28
28
  task :grind => :run do
29
29
  system "kcachegrind /tmp/liquor.rubyprof_calltreeprinter.txt"
30
30
  end
31
31
  end
32
-
33
-
@@ -2,7 +2,7 @@
2
2
  # and use liquid as an template system for .liquid files
3
3
  #
4
4
  # Example
5
- #
5
+ #
6
6
  # ActionView::Base::register_template_handler :liquid, LiquidView
7
7
  class LiquidView
8
8
  PROTECTED_ASSIGNS = %w( template_root response _session template_class action_name request_origin session template
@@ -10,7 +10,7 @@ class LiquidView
10
10
  ignore_missing_templates flash _params logger before_filter_chain_aborted headers )
11
11
  PROTECTED_INSTANCE_VARIABLES = %w( @_request @controller @_first_render @_memoized__pick_template @view_paths
12
12
  @helpers @assigns_added @template @_render_stack @template_format @assigns )
13
-
13
+
14
14
  def self.call(template)
15
15
  "LiquidView.new(self).render(template, local_assigns)"
16
16
  end
@@ -18,10 +18,10 @@ class LiquidView
18
18
  def initialize(view)
19
19
  @view = view
20
20
  end
21
-
21
+
22
22
  def render(template, local_assigns = nil)
23
23
  @view.controller.headers["Content-Type"] ||= 'text/html; charset=utf-8'
24
-
24
+
25
25
  # Rails 2.2 Template has source, but not locals
26
26
  if template.respond_to?(:source) && !template.respond_to?(:locals)
27
27
  assigns = (@view.instance_variables - PROTECTED_INSTANCE_VARIABLES).inject({}) do |hash, ivar|
@@ -31,15 +31,15 @@ class LiquidView
31
31
  else
32
32
  assigns = @view.assigns.reject{ |k,v| PROTECTED_ASSIGNS.include?(k) }
33
33
  end
34
-
34
+
35
35
  source = template.respond_to?(:source) ? template.source : template
36
36
  local_assigns = (template.respond_to?(:locals) ? template.locals : local_assigns) || {}
37
-
37
+
38
38
  if content_for_layout = @view.instance_variable_get("@content_for_layout")
39
39
  assigns['content_for_layout'] = content_for_layout
40
40
  end
41
41
  assigns.merge!(local_assigns.stringify_keys)
42
-
42
+
43
43
  liquid = Liquid::Template.parse(source)
44
44
  liquid.render(assigns, :filters => [@view.controller.master_helper_module], :registers => {:action_view => @view, :controller => @view.controller})
45
45
  end
@@ -2,7 +2,7 @@
2
2
  # and use liquor as an template system for .liquor files
3
3
  #
4
4
  # Example
5
- #
5
+ #
6
6
  # ActionView::Base::register_template_handler :liquor, LiquorView
7
7
  class LiquorView
8
8
  PROTECTED_ASSIGNS = %w( template_root response _session template_class action_name request_origin session template
@@ -10,7 +10,7 @@ class LiquorView
10
10
  ignore_missing_templates flash _params logger before_filter_chain_aborted headers )
11
11
  PROTECTED_INSTANCE_VARIABLES = %w( @_request @controller @_first_render @_memoized__pick_template @view_paths
12
12
  @helpers @assigns_added @template @_render_stack @template_format @assigns )
13
-
13
+
14
14
  def self.call(template)
15
15
  "LiquorView.new(self).render(template, local_assigns)"
16
16
  end
@@ -18,10 +18,10 @@ class LiquorView
18
18
  def initialize(view)
19
19
  @view = view
20
20
  end
21
-
21
+
22
22
  def render(template, local_assigns = nil)
23
23
  @view.controller.headers["Content-Type"] ||= 'text/html; charset=utf-8'
24
-
24
+
25
25
  # Rails 2.2 Template has source, but not locals
26
26
  if template.respond_to?(:source) && !template.respond_to?(:locals)
27
27
  assigns = (@view.instance_variables - PROTECTED_INSTANCE_VARIABLES).inject({}) do |hash, ivar|
@@ -31,15 +31,15 @@ class LiquorView
31
31
  else
32
32
  assigns = @view.assigns.reject{ |k,v| PROTECTED_ASSIGNS.include?(k) }
33
33
  end
34
-
34
+
35
35
  source = template.respond_to?(:source) ? template.source : template
36
36
  local_assigns = (template.respond_to?(:locals) ? template.locals : local_assigns) || {}
37
-
37
+
38
38
  if content_for_layout = @view.instance_variable_get("@content_for_layout")
39
39
  assigns['content_for_layout'] = content_for_layout
40
40
  end
41
41
  assigns.merge!(local_assigns.stringify_keys)
42
-
42
+
43
43
  liquor = Liquor::Template.parse(source)
44
44
  liquor.render(assigns, :filters => [@view.controller.master_helper_module], :registers => {:action_view => @view, :controller => @view.controller})
45
45
  end
@@ -1,3 +1,3 @@
1
1
  module Liquor
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
data/liquor.gemspec CHANGED
@@ -2,8 +2,8 @@
2
2
  require File.expand_path('../lib/liquor/version', __FILE__)
3
3
 
4
4
  Gem::Specification.new do |gem|
5
- gem.authors = ["Ivan Evtukhovich"]
6
- gem.email = ["evtuhovich@gmail.com"]
5
+ gem.authors = ["Timothy N. Tsvetkov", "Yaroslav Markin", "Ivan Evtukhovich"]
6
+ gem.email = ["timothy.tsvetkov@gmail.com"]
7
7
  gem.description = %q{Liquor is a safe (not evaling) template language based on Liquid template language}
8
8
  gem.summary = %q{Liquor is a safe (not evaling) template language based on Liquid template language. Safe means that templates cannot affect security of the server they are rendered on. So it is usable when you need to give an ability to edit templates to your users (HTML or email).}
9
9
  gem.homepage = "https://github.com/evilmartians/liquor"
metadata CHANGED
@@ -1,48 +1,37 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: liquor
3
- version: !ruby/object:Gem::Version
4
- hash: 27
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1
5
5
  prerelease:
6
- segments:
7
- - 0
8
- - 1
9
- - 0
10
- version: 0.1.0
11
6
  platform: ruby
12
- authors:
7
+ authors:
8
+ - Timothy N. Tsvetkov
9
+ - Yaroslav Markin
13
10
  - Ivan Evtukhovich
14
11
  autorequire:
15
12
  bindir: bin
16
13
  cert_chain: []
17
-
18
- date: 2012-05-10 00:00:00 Z
19
- dependencies:
20
- - !ruby/object:Gem::Dependency
14
+ date: 2012-05-10 00:00:00.000000000 Z
15
+ dependencies:
16
+ - !ruby/object:Gem::Dependency
21
17
  name: rails
22
- version_requirements: &id001 !ruby/object:Gem::Requirement
18
+ requirement: &70145564706620 !ruby/object:Gem::Requirement
23
19
  none: false
24
- requirements:
20
+ requirements:
25
21
  - - ~>
26
- - !ruby/object:Gem::Version
27
- hash: 15
28
- segments:
29
- - 3
30
- - 2
31
- - 0
22
+ - !ruby/object:Gem::Version
32
23
  version: 3.2.0
33
24
  type: :runtime
34
- requirement: *id001
35
25
  prerelease: false
36
- description: Liquor is a safe (not evaling) template language based on Liquid template language
37
- email:
38
- - evtuhovich@gmail.com
26
+ version_requirements: *70145564706620
27
+ description: Liquor is a safe (not evaling) template language based on Liquid template
28
+ language
29
+ email:
30
+ - timothy.tsvetkov@gmail.com
39
31
  executables: []
40
-
41
32
  extensions: []
42
-
43
33
  extra_rdoc_files: []
44
-
45
- files:
34
+ files:
46
35
  - .travis.yml
47
36
  - AUTHORS
48
37
  - CHANGELOG
@@ -52,7 +41,6 @@ files:
52
41
  - LICENSE
53
42
  - MIT-LICENSE
54
43
  - README.md
55
- - README.rdoc
56
44
  - Rakefile
57
45
  - example/server/example_servlet.rb
58
46
  - example/server/liquid_servlet.rb
@@ -173,38 +161,32 @@ files:
173
161
  - test/yield_test.rb
174
162
  homepage: https://github.com/evilmartians/liquor
175
163
  licenses: []
176
-
177
164
  post_install_message:
178
165
  rdoc_options: []
179
-
180
- require_paths:
166
+ require_paths:
181
167
  - lib
182
- required_ruby_version: !ruby/object:Gem::Requirement
168
+ required_ruby_version: !ruby/object:Gem::Requirement
183
169
  none: false
184
- requirements:
185
- - - ">="
186
- - !ruby/object:Gem::Version
187
- hash: 3
188
- segments:
189
- - 0
190
- version: "0"
191
- required_rubygems_version: !ruby/object:Gem::Requirement
170
+ requirements:
171
+ - - ! '>='
172
+ - !ruby/object:Gem::Version
173
+ version: '0'
174
+ required_rubygems_version: !ruby/object:Gem::Requirement
192
175
  none: false
193
- requirements:
194
- - - ">="
195
- - !ruby/object:Gem::Version
196
- hash: 3
197
- segments:
198
- - 0
199
- version: "0"
176
+ requirements:
177
+ - - ! '>='
178
+ - !ruby/object:Gem::Version
179
+ version: '0'
200
180
  requirements: []
201
-
202
181
  rubyforge_project:
203
- rubygems_version: 1.8.23
182
+ rubygems_version: 1.8.17
204
183
  signing_key:
205
184
  specification_version: 3
206
- summary: Liquor is a safe (not evaling) template language based on Liquid template language. Safe means that templates cannot affect security of the server they are rendered on. So it is usable when you need to give an ability to edit templates to your users (HTML or email).
207
- test_files:
185
+ summary: Liquor is a safe (not evaling) template language based on Liquid template
186
+ language. Safe means that templates cannot affect security of the server they are
187
+ rendered on. So it is usable when you need to give an ability to edit templates
188
+ to your users (HTML or email).
189
+ test_files:
208
190
  - test/assign_test.rb
209
191
  - test/block_test.rb
210
192
  - test/capture_test.rb
data/README.rdoc DELETED
@@ -1,114 +0,0 @@
1
- https://secure.travis-ci.org/evilmartians/liquor.png
2
-
3
- Travis[http://travis-ci.org/evilmartians/liquor]
4
-
5
- =Liquor template engine
6
-
7
- Liquor is a safe (not evaling) template language based on Liquid template language. Safe means that templates cannot affect security of the server they are rendered on. So it is usable when you need to give an ability to edit templates to your users (HTML or email).
8
-
9
- ==What does it look like?
10
-
11
- <ul id="products">
12
- {% for product in products %}
13
- <li>
14
- <h2>{{product.name}}</h2>
15
- Only {{product.price | price }}
16
-
17
- {{product.description | prettyprint | paragraph }}
18
- </li>
19
- {% endfor %}
20
- </ul>
21
-
22
- ==Howto use Liquor
23
-
24
- Liquid supports a very simple API based around the Liquor::Template class.
25
- For standard use you can just pass it the content of a file and call render with a parameters hash.
26
-
27
- @template = Liquid::Template.parse("hi {{name}}") # Parses and compiles the template
28
- @template.render( 'name' => '2kan' ) # => "hi 2kan"
29
-
30
- ==Differs from Liquid
31
-
32
- You can find Liquid docs here: http://github.com/tobi/liquid/wiki
33
-
34
- ===Liquor Drops
35
- Liquor drops are really powerful now. Now you can define access to methods, named scopes and relations.
36
-
37
- ====Attributes
38
- To define attributes you need just add line with with attributes you want to provide access to:
39
-
40
- class MyDrop < Liquor::Drop
41
- self.liquor_attributes << :title << :body
42
- end
43
-
44
- ====Named Scopes
45
- To define access to named scopes (result automatically will be converted to array of liquor drops):
46
-
47
- class MyDrop < Liquor::Drop
48
- self.liquor_scopes << :recent << :limit << :scoped_to_user
49
- end
50
-
51
- Named scopes works like filters in templates. Don't worry about passing drop objects in templates as params in real calls they will be converted back to objects and then result will be converted to array of drops.
52
-
53
- ====Relations
54
-
55
- We have now has_many, has_one and belongs_to relations. You don't need to pass any additional parameters to has_one or belongs_to relations because you just define ability to call real methods (results will be converted to liquid drops).
56
-
57
- But has_many method a bit more complicated since it defines a special proxy object from which you can call your named_scopes. There are several options for has_many relation:
58
-
59
- * class_name — A drop class name (ex. PostDrop)
60
- * sort_scope — Default scope for sorting objects in relations. If you class responds_to recent it will be used as the default one.
61
- * source_class_name — Class name of the source class (ex. Post)
62
- * with_scope — this scope always will be used for this relation
63
-
64
- ===Named Scope
65
-
66
- Sometimes you need to pass a Named Scope object to a template. Now it is possible. When you assign a NamedScope to a template it assigns as is. But you are not able to execute any methods except array methods and paginate method, the last one was added for for better integration with will_paginate plugin.
67
-
68
- ===Tags
69
-
70
- Two new tags were added: content_for and yield.
71
-
72
- Within the context of a layout, yield identifies a section where content from the view should be inserted.
73
- The simplest way to use this is to have a single yield, into which the entire contents of the view currently being rendered is inserted.
74
-
75
- In your layout:
76
- <title>{% yield title %}</title>
77
- <body>{% yield %}</body>
78
-
79
- In the view:
80
- {% content_for title %} The title {% end_content_for %}
81
- The body
82
-
83
-
84
- Will produce:
85
- <title>The title</title>
86
- <body>The body</body>
87
-
88
- ===Filters
89
-
90
- Few filters were added:
91
-
92
- * yield — yield for content_for tag
93
- * in_groups_of — splits over the array in groups of size num padding any remaining slots with fill_with unless it is false
94
- * in_groups — splits or iterates over the array in number of groups, padding any remaining slots with fill_with unless it is false
95
- * include — returns true if the given object is present in self (that is, if any object == anObject), false otherwise.
96
- * to_json — return a JSON string representing the model drop (using accepted attributes, methods and named_scopes) to_include is a list of related drops through associations
97
- * url_escape — escape url
98
- * reverse — returns a new array containing self’s elements in reverse order.
99
- * decode_html_entities — decodes html entities
100
- * split — divides str into substrings based on a delimiter, returning an array of these substrings.
101
- * compact — returns a copy of self with all nil elements removed.
102
- * concat — concatenates two arrays
103
-
104
- ===Expressions
105
-
106
- You can execute expressions in tags using standard filters syntax but spaces around separator are not allowed.
107
- This is correct expression:
108
- {% assign playlist_array = site.playlists|by_name:artist.name %}
109
-
110
- And this is not:
111
- {% assign playlist_array = site.playlists | by_name:artist.name %}
112
-
113
- You can use expressions in other tags for example in for loops:
114
- {% for artist in site.artists.active.with_orders|scoped_to:genre %}