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 +4 -4
- data/CHANGELOG.md +9 -1
- data/README.md +6 -0
- data/lib/liquid-rails/rspec/view_controller_context.rb +1 -1
- data/lib/liquid-rails/tags/google_analytics_tag.rb +6 -9
- data/lib/liquid-rails/template_handler.rb +2 -2
- data/lib/liquid-rails/version.rb +1 -1
- data/spec/dummy/app/controllers/home_controller.rb +4 -1
- data/spec/dummy/app/views/home/_html_liquid_partial.liquid +1 -0
- data/spec/dummy/app/views/home/erb_with_html_liquid_partial.erb +1 -0
- data/spec/dummy/config/routes.rb +2 -0
- data/spec/lib/liquid-rails/tags/google_analtyics_tag_spec.rb +6 -9
- data/spec/lib/liquid-rails/template_handler_spec.rb +13 -5
- metadata +6 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 54955a6c51334d96d643bbbbd38c1525249fd772
|
4
|
+
data.tar.gz: b950dc24be7dd7bd91cf7694006c8a4de8791cff
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 58bf7986347e7bf2785b23765b16f9061b94f3c86f0e29d9d22e3ae049e835de7ed2e1aabbf0e4ec9a796cf622b29a5ad149033eb1e9212943972ed5a53c0aa6
|
7
|
+
data.tar.gz: 2a2ee583078fc85af996b4f58185d790a4fdc3a9dc5ae4dfdda6f8d4c58d9f5f2c5e8d35a0bc86592d977952a0f6beb061c46bcde08d5c779aceb25b2754199b
|
data/CHANGELOG.md
CHANGED
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 `|`.
|
@@ -23,15 +23,12 @@ module Liquid
|
|
23
23
|
%{
|
24
24
|
<script type="text/javascript">
|
25
25
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
(
|
31
|
-
|
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
|
data/lib/liquid-rails/version.rb
CHANGED
@@ -0,0 +1 @@
|
|
1
|
+
<p>Partial Content</p>
|
@@ -0,0 +1 @@
|
|
1
|
+
<%= render 'html_liquid_partial' %>
|
data/spec/dummy/config/routes.rb
CHANGED
@@ -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
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
(
|
20
|
-
|
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
|
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
|
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
|
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
|
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.
|
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-
|
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
|