templates 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
@@ -21,39 +21,36 @@ module Templates
|
|
21
21
|
if controller_file_name =~ /_controller/
|
22
22
|
controller_name = controller_file_name.camelize.gsub('.rb', '')
|
23
23
|
|
24
|
-
|
24
|
+
controller = controller_name.constantize
|
25
|
+
templates_hash = {}
|
25
26
|
|
26
|
-
|
27
|
-
templates_hash = {}
|
27
|
+
unless controller.templates_options.nil?
|
28
28
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
templates_hash[:layout] = render_to_string(:file => "layouts/#{controller.controller_name}", :layout => false)
|
33
|
-
end
|
29
|
+
if controller.templates_options[:layout]
|
30
|
+
templates_hash[:layout] = render_to_string(:file => "layouts/#{controller.controller_name}", :layout => false)
|
31
|
+
end
|
34
32
|
|
35
|
-
|
33
|
+
if controller.templates_options[:partials].count > 0
|
36
34
|
|
37
|
-
|
35
|
+
templates_hash[:partials] = {}
|
38
36
|
|
39
|
-
|
40
|
-
|
41
|
-
end
|
37
|
+
controller.templates_options[:partials].each do |partial|
|
38
|
+
templates_hash[:partials][partial] = render_to_string(:file => "#{controller.controller_name}/_#{partial}", :layout => false)
|
42
39
|
end
|
43
|
-
|
44
40
|
end
|
45
41
|
|
46
|
-
|
42
|
+
end
|
43
|
+
|
44
|
+
if not controller.templates_list.nil? and controller.templates_list.count > 0
|
47
45
|
|
48
|
-
|
46
|
+
templates_hash[:templates] = {}
|
49
47
|
|
50
|
-
|
51
|
-
|
52
|
-
end
|
48
|
+
controller.templates_list.each do |template|
|
49
|
+
templates_hash[:templates][template] = render_to_string(:file => "#{controller.controller_name}/#{template}", :layout => false)
|
53
50
|
end
|
54
|
-
|
55
|
-
app_templates[controller.controller_name] = templates_hash unless templates_hash.empty?
|
56
51
|
end
|
52
|
+
|
53
|
+
app_templates[controller.controller_name] = templates_hash unless templates_hash.empty?
|
57
54
|
end
|
58
55
|
end
|
59
56
|
|
@@ -61,7 +58,22 @@ module Templates
|
|
61
58
|
end
|
62
59
|
|
63
60
|
def last_modify
|
64
|
-
|
61
|
+
# Watched files (and dirs) list
|
62
|
+
watched_files = %w[
|
63
|
+
app/views
|
64
|
+
app/helpers
|
65
|
+
config/locales
|
66
|
+
config/routes.rb
|
67
|
+
].map { |f| [Rails.root, f].join('/') }
|
68
|
+
|
69
|
+
stat_flags = if RUBY_PLATFORM =~ /darwin/
|
70
|
+
# Mac OS X
|
71
|
+
'-f %m'
|
72
|
+
else
|
73
|
+
# Linux (it may work on Windows, but in fact I'm really don't care about this crap)
|
74
|
+
'--format=%Y'
|
75
|
+
end
|
76
|
+
`stat #{stat_flags} $(ls -t $(find #{ watched_files.join(' ') } -type f) | head -n 1)`.strip
|
65
77
|
end
|
66
78
|
|
67
79
|
end
|
data/lib/templates/version.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: templates
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 19
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 2
|
9
|
-
-
|
10
|
-
version: 0.2.
|
9
|
+
- 2
|
10
|
+
version: 0.2.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Sasha Koss
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-
|
18
|
+
date: 2011-06-12 00:00:00 Z
|
19
19
|
dependencies: []
|
20
20
|
|
21
21
|
description: Rails engine which render selected templates to json
|