liquid-rails 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 60effe936f0e73722ccb5017936e8ebd3194225a
4
- data.tar.gz: 5184c687fab2ae2966cce49ca46d78576936889e
3
+ metadata.gz: 54955a6c51334d96d643bbbbd38c1525249fd772
4
+ data.tar.gz: b950dc24be7dd7bd91cf7694006c8a4de8791cff
5
5
  SHA512:
6
- metadata.gz: cc4fbd79de3c6d0f6529bc597184553dfb2abdce2a195f48d641f1179ab52c5a7ad8401cb71b2131306409252173e6a573beb4a4bd64f95b90c78e60b0a872a3
7
- data.tar.gz: bba6ac533ec927f2619948a5761e7ed3230080133f551774371b0e7aaa9b67d564946831452a0f7b73a70d9bd6280142bf9a2b92212e55061f8db40f5c3ebc4b
6
+ metadata.gz: 58bf7986347e7bf2785b23765b16f9061b94f3c86f0e29d9d22e3ae049e835de7ed2e1aabbf0e4ec9a796cf622b29a5ad149033eb1e9212943972ed5a53c0aa6
7
+ data.tar.gz: 2a2ee583078fc85af996b4f58185d790a4fdc3a9dc5ae4dfdda6f8d4c58d9f5f2c5e8d35a0bc86592d977952a0f6beb061c46bcde08d5c779aceb25b2754199b
@@ -1,6 +1,14 @@
1
1
  # Overview
2
2
 
3
- ## 0.1.1 - Not released
3
+ ## 0.1.2
4
+
5
+ ### New Features
6
+
7
+ * Use google analytics universal (Chamnap Chhorn)
8
+
9
+ * Render liquid template as html_safe by default (Dan Kubb)
10
+
11
+ ## 0.1.1
4
12
 
5
13
  ### New Features
6
14
 
data/README.md CHANGED
@@ -51,6 +51,12 @@ def liquid_filters
51
51
  end
52
52
  ```
53
53
 
54
+ You can render liquid templates from other template engines, eg. `erb`, `haml`, ...
55
+
56
+ ```ruby
57
+ = render 'shared/partial.liquid'
58
+ ```
59
+
54
60
  ### Filter
55
61
 
56
62
  > Filters are simple methods that modify the output of numbers, strings, variables and objects. They are placed within an output tag `{{` `}}` and are separated with a pipe character `|`.
@@ -37,7 +37,7 @@ module Liquid
37
37
  end
38
38
 
39
39
  actual = Liquid::Template.parse(template).render!(context)
40
- expect(actual.strip).to eq(expected.strip)
40
+ expect(actual.to_s.strip).to eq(expected.to_s.strip)
41
41
  end
42
42
  end
43
43
  end
@@ -23,15 +23,12 @@ module Liquid
23
23
  %{
24
24
  <script type="text/javascript">
25
25
 
26
- var _gaq = _gaq || [];
27
- _gaq.push(['_setAccount', '#{@account_id}']);
28
- _gaq.push(['_trackPageview']);
29
-
30
- (function() {
31
- var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
32
- ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
33
- var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
34
- })();
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');
35
32
 
36
33
  </script>
37
34
  }
@@ -25,7 +25,7 @@ module Liquid
25
25
 
26
26
  liquid = Liquid::Template.parse(template)
27
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 })
28
+ liquid.send(render_method, assigns, filters: filters, registers: { view: @view, controller: @controller, helper: @helper }).html_safe
29
29
  end
30
30
 
31
31
  def filters
@@ -41,4 +41,4 @@ module Liquid
41
41
  end
42
42
  end
43
43
  end
44
- end
44
+ end
@@ -1,5 +1,5 @@
1
1
  module Liquid
2
2
  module Rails
3
- VERSION = '0.1.1'
3
+ VERSION = '0.1.2'
4
4
  end
5
5
  end
@@ -17,9 +17,12 @@ class HomeController < ApplicationController
17
17
  def index_with_filter
18
18
  end
19
19
 
20
+ def erb_with_html_liquid_partial
21
+ end
22
+
20
23
  private
21
24
 
22
25
  def set_book
23
26
  @book = { 'name' => 'Liquid on Rails' }
24
27
  end
25
- end
28
+ end
@@ -0,0 +1 @@
1
+ <p>Partial Content</p>
@@ -0,0 +1 @@
1
+ <%= render 'html_liquid_partial' %>
@@ -8,5 +8,7 @@ Rails.application.routes.draw do
8
8
  get '/index_partial', to: 'home#index_partial'
9
9
  get '/index_partial_with_full_path', to: 'home#index_partial_with_full_path'
10
10
 
11
+ get '/erb_with_html_liquid_partial', to: 'home#erb_with_html_liquid_partial'
12
+
11
13
  get '/foospace/bar/index_partial', to: 'foospace/bar#index_partial'
12
14
  end
@@ -12,15 +12,12 @@ module Liquid
12
12
  %{
13
13
  <script type="text/javascript">
14
14
 
15
- var _gaq = _gaq || [];
16
- _gaq.push(['_setAccount', 'UA-XXXXX-X']);
17
- _gaq.push(['_trackPageview']);
18
-
19
- (function() {
20
- var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
21
- ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
22
- var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
23
- })();
15
+ (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
16
+ (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
17
+ m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
18
+ })(window,document,'script','//www.google-analytics.com/analytics.js','ga');
19
+ ga('create', 'UA-XXXXX-X', 'auto');
20
+ ga('send', 'pageview');
24
21
 
25
22
  </script>
26
23
  }
@@ -5,7 +5,7 @@ describe 'Request', type: :feature do
5
5
  it 'renders with liquid template' do
6
6
  visit '/'
7
7
 
8
- expect(page.body).to eq 'Liquid on Rails'
8
+ expect(page.body).to eq('Liquid on Rails')
9
9
  end
10
10
 
11
11
  it 'sets content_type as html by default' do
@@ -19,7 +19,7 @@ describe 'Request', type: :feature do
19
19
  it 'renders with layout' do
20
20
  visit '/index_with_layout'
21
21
 
22
- expect(page.body).to eq "Application Layout\nLiquid on Rails"
22
+ expect(page.body).to eq("Application Layout\nLiquid on Rails")
23
23
  end
24
24
  end
25
25
 
@@ -27,20 +27,20 @@ describe 'Request', type: :feature do
27
27
  it 'no full path for the current controller' do
28
28
  visit '/index_partial'
29
29
 
30
- expect(page.body).to eq "Application Layout\nLiquid on Rails\n\nHome Partial\nShared Partial"
30
+ expect(page.body).to eq("Application Layout\nLiquid on Rails\n\nHome Partial\nShared Partial")
31
31
  end
32
32
 
33
33
  it 'full path' do
34
34
  visit '/index_partial_with_full_path'
35
35
 
36
- expect(page.body).to eq "Application Layout\nLiquid on Rails\n\nHome Partial\nShared Partial"
36
+ expect(page.body).to eq("Application Layout\nLiquid on Rails\n\nHome Partial\nShared Partial")
37
37
  end
38
38
 
39
39
  it 'respects namespace of original template for partials path' do
40
40
  visit '/foospace/bar/index_partial'
41
+
41
42
  expect(page.body.strip).to eq("Foospace::BarController\n\nBar Partial")
42
43
  end
43
-
44
44
  end
45
45
 
46
46
  context 'render with filter' do
@@ -56,4 +56,12 @@ describe 'Request', type: :feature do
56
56
  expect(page.body).to eq("Application Layout\nLiquid on Rails\nThis is a long section of text")
57
57
  end
58
58
  end
59
+
60
+ context 'render html within an erb template' do
61
+ it 'does not escape the html' do
62
+ visit '/erb_with_html_liquid_partial'
63
+
64
+ expect(page.body.strip).to eq("Application Layout\n<p>Partial Content</p>")
65
+ end
66
+ end
59
67
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: liquid-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chamnap Chhorn
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-02-12 00:00:00.000000000 Z
11
+ date: 2015-05-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -123,7 +123,9 @@ files:
123
123
  - spec/dummy/app/models/concerns/.keep
124
124
  - spec/dummy/app/views/foospace/bar/_partial.liquid
125
125
  - spec/dummy/app/views/foospace/bar/index_partial.liquid
126
+ - spec/dummy/app/views/home/_html_liquid_partial.liquid
126
127
  - spec/dummy/app/views/home/_partial.liquid
128
+ - spec/dummy/app/views/home/erb_with_html_liquid_partial.erb
127
129
  - spec/dummy/app/views/home/index.liquid
128
130
  - spec/dummy/app/views/home/index_partial.liquid
129
131
  - spec/dummy/app/views/home/index_partial_with_full_path.liquid
@@ -216,7 +218,9 @@ test_files:
216
218
  - spec/dummy/app/models/concerns/.keep
217
219
  - spec/dummy/app/views/foospace/bar/_partial.liquid
218
220
  - spec/dummy/app/views/foospace/bar/index_partial.liquid
221
+ - spec/dummy/app/views/home/_html_liquid_partial.liquid
219
222
  - spec/dummy/app/views/home/_partial.liquid
223
+ - spec/dummy/app/views/home/erb_with_html_liquid_partial.erb
220
224
  - spec/dummy/app/views/home/index.liquid
221
225
  - spec/dummy/app/views/home/index_partial.liquid
222
226
  - spec/dummy/app/views/home/index_partial_with_full_path.liquid