smt_rails 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -0
- data/README.md +5 -1
- data/lib/smt_rails/tilt.rb +9 -2
- data/lib/smt_rails/version.rb +1 -1
- metadata +10 -10
data/.gitignore
CHANGED
data/README.md
CHANGED
@@ -11,6 +11,10 @@ Add this line to your application's Gemfile:
|
|
11
11
|
And then execute:
|
12
12
|
|
13
13
|
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install smt_rails
|
14
18
|
|
15
19
|
## Usage
|
16
20
|
|
@@ -30,7 +34,7 @@ In view you can render this template by this way:
|
|
30
34
|
|
31
35
|
The same template you can render in JavaScript:
|
32
36
|
|
33
|
-
var content = SMT['templates/
|
37
|
+
var content = SMT['templates/test']({msg: "Test"});
|
34
38
|
|
35
39
|
## Configuration
|
36
40
|
|
data/lib/smt_rails/tilt.rb
CHANGED
@@ -13,12 +13,19 @@ module SmtRails
|
|
13
13
|
attr_reader :namespace
|
14
14
|
|
15
15
|
def evaluate(scope, locals, &block)
|
16
|
+
template_key = path_to_key scope
|
16
17
|
<<-MustacheTemplate
|
17
|
-
(function() {
|
18
|
+
(function() {
|
18
19
|
#{namespace} || (#{namespace} = {});
|
19
|
-
#{namespace}[#{
|
20
|
+
#{namespace}[#{template_key.inspect}] = function(object) { return Mustache.render(#{data.inspect}, object) };
|
20
21
|
}).call(this);
|
21
22
|
MustacheTemplate
|
22
23
|
end
|
24
|
+
|
25
|
+
def path_to_key(scope)
|
26
|
+
path = scope.logical_path.to_s.split('/')
|
27
|
+
path.last.gsub!(/^_/, '')
|
28
|
+
path.join('/')
|
29
|
+
end
|
23
30
|
end
|
24
31
|
end
|
data/lib/smt_rails/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: smt_rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,11 +10,11 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2012-04-
|
13
|
+
date: 2012-04-13 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rails
|
17
|
-
requirement: &
|
17
|
+
requirement: &70145481535460 !ruby/object:Gem::Requirement
|
18
18
|
none: false
|
19
19
|
requirements:
|
20
20
|
- - ! '>='
|
@@ -22,10 +22,10 @@ dependencies:
|
|
22
22
|
version: 3.1.0
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
|
-
version_requirements: *
|
25
|
+
version_requirements: *70145481535460
|
26
26
|
- !ruby/object:Gem::Dependency
|
27
27
|
name: tilt
|
28
|
-
requirement: &
|
28
|
+
requirement: &70145481534880 !ruby/object:Gem::Requirement
|
29
29
|
none: false
|
30
30
|
requirements:
|
31
31
|
- - ! '>='
|
@@ -33,10 +33,10 @@ dependencies:
|
|
33
33
|
version: 1.3.3
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
|
-
version_requirements: *
|
36
|
+
version_requirements: *70145481534880
|
37
37
|
- !ruby/object:Gem::Dependency
|
38
38
|
name: sprockets
|
39
|
-
requirement: &
|
39
|
+
requirement: &70145481532380 !ruby/object:Gem::Requirement
|
40
40
|
none: false
|
41
41
|
requirements:
|
42
42
|
- - ! '>='
|
@@ -44,10 +44,10 @@ dependencies:
|
|
44
44
|
version: 2.0.3
|
45
45
|
type: :runtime
|
46
46
|
prerelease: false
|
47
|
-
version_requirements: *
|
47
|
+
version_requirements: *70145481532380
|
48
48
|
- !ruby/object:Gem::Dependency
|
49
49
|
name: mustache
|
50
|
-
requirement: &
|
50
|
+
requirement: &70145481530980 !ruby/object:Gem::Requirement
|
51
51
|
none: false
|
52
52
|
requirements:
|
53
53
|
- - ! '>='
|
@@ -55,7 +55,7 @@ dependencies:
|
|
55
55
|
version: 0.99.4
|
56
56
|
type: :runtime
|
57
57
|
prerelease: false
|
58
|
-
version_requirements: *
|
58
|
+
version_requirements: *70145481530980
|
59
59
|
description: Shared mustache templates for rails 3
|
60
60
|
email:
|
61
61
|
- contacts@railsware.com
|