so_meta 0.4 → 0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +29 -4
- data/lib/so_meta/helper.rb +10 -4
- data/lib/so_meta/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b8b5dab5be34c8b465e9313abe792521d1b52258
|
4
|
+
data.tar.gz: 8d55ab735692ac036d18fd12807ca25ed6f2b6e4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3abc45e2c45a73264e51d4dd72d8d4300f4b5bf85db500a52cb8862e2501264e05ed0cbd8c135823fa662fb286d943215515d79fece2678bd61b65d72495d57d
|
7
|
+
data.tar.gz: 32b60b76f571299926a31c0fa0a2e2c1801a4e6a229736e0e5a1f3e5b978928c45b5344a8f905ee6d8c2d036c5d4d5143a18a88ea8bddc87e017cf488174d62c
|
data/README.md
CHANGED
@@ -40,9 +40,6 @@ en:
|
|
40
40
|
title: "About | My Awesome New Rails Application"
|
41
41
|
description: "Our company will blow your mind...like really."
|
42
42
|
|
43
|
-
iphone:
|
44
|
-
title: "iPhone About | My Awesome New Rails Application"
|
45
|
-
|
46
43
|
contact:
|
47
44
|
title: "Contact %{name} | My Awesome New Rails Application" # Interpolation content from the view
|
48
45
|
# By not specifying a description for this page, it'll inherit the defaults
|
@@ -54,7 +51,7 @@ en:
|
|
54
51
|
<!DOCTYPE html>
|
55
52
|
<html lang="en">
|
56
53
|
<head>
|
57
|
-
<title><%= so_meta(:title
|
54
|
+
<title><%= so_meta(:title) %></title>
|
58
55
|
<meta name="description" content="<%= so_meta(:description) %>" />
|
59
56
|
<%= csrf_meta_tags %>
|
60
57
|
</head>
|
@@ -72,6 +69,34 @@ en:
|
|
72
69
|
<p>Contact us now!</p>
|
73
70
|
```
|
74
71
|
|
72
|
+
### Usage with scoping
|
73
|
+
|
74
|
+
```Erb
|
75
|
+
<title><%= so_meta(:title, :phone) %></title>
|
76
|
+
```
|
77
|
+
|
78
|
+
```YAML
|
79
|
+
# config/locales/en.yml
|
80
|
+
|
81
|
+
en:
|
82
|
+
so_meta:
|
83
|
+
defaults:
|
84
|
+
title: "My Awesome New Rails Application"
|
85
|
+
description: "This application will be so viral, your startup
|
86
|
+
friends will be JEALOUS!"
|
87
|
+
|
88
|
+
pages: # Controller name - PagesController
|
89
|
+
about: # Action name - about
|
90
|
+
title: "About | My Awesome New Rails Application"
|
91
|
+
description: "Our company will blow your mind...like really."
|
92
|
+
|
93
|
+
phone:
|
94
|
+
title: "Specific title for phone" # will choose this if the scope
|
95
|
+
matches
|
96
|
+
```
|
97
|
+
|
98
|
+
|
99
|
+
|
75
100
|
## Contributing
|
76
101
|
|
77
102
|
1. Fork it
|
data/lib/so_meta/helper.rb
CHANGED
@@ -1,15 +1,21 @@
|
|
1
|
+
require 'pry'
|
2
|
+
|
1
3
|
module SoMeta
|
2
4
|
module Helper
|
3
5
|
def so_meta(name, scope = nil)
|
4
6
|
interpolation_data = instance_variable_get("@so_meta_#{name}_interpolation") || {}
|
5
7
|
|
6
|
-
|
8
|
+
request_key = "so_meta.#{controller_path.gsub(/\//, "_")}.#{action_name}"
|
7
9
|
|
8
10
|
if scope.present?
|
9
|
-
|
10
|
-
|
11
|
-
|
11
|
+
begin
|
12
|
+
return I18n.translate!("#{request_key}.#{scope}.#{name}")
|
13
|
+
rescue I18n::MissingTranslationData
|
14
|
+
nil
|
15
|
+
end
|
12
16
|
end
|
17
|
+
|
18
|
+
t("#{request_key}.#{name}", interpolation_data.merge(default: t("so_meta.defaults.#{name}")))
|
13
19
|
end
|
14
20
|
|
15
21
|
def so_meta_interpolation(name, hash)
|
data/lib/so_meta/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: so_meta
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '0.
|
4
|
+
version: '0.6'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brandon Hilkert
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-08-
|
11
|
+
date: 2016-08-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|