RubyApp 0.0.69 → 0.0.70
Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile.lock
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
%span.link{attributes}
|
4
4
|
- if self.current_page?
|
5
5
|
%span.current{:href => '', :page => self.page}
|
6
|
-
=
|
6
|
+
= yield(self.page) || self.page.translate.title
|
7
7
|
- else
|
8
8
|
%a.page{:href => '', :page => self.page}
|
9
|
-
=
|
9
|
+
= yield(self.page) || self.page.translate.title
|
@@ -1,7 +1,6 @@
|
|
1
1
|
require 'rubygems'
|
2
2
|
require 'bundler/setup'
|
3
3
|
|
4
|
-
require 'facets/string/interpolate'
|
5
4
|
require 'haml'
|
6
5
|
|
7
6
|
module RubyApp
|
@@ -9,28 +8,17 @@ module RubyApp
|
|
9
8
|
module Mixins
|
10
9
|
|
11
10
|
module RenderMixin
|
11
|
+
require 'ruby_app/request'
|
12
12
|
|
13
13
|
def rendered?(template)
|
14
|
-
unless
|
14
|
+
unless RubyApp::Request.rendered?(template)
|
15
15
|
yield
|
16
|
-
|
16
|
+
RubyApp::Request.rendered(template)
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
20
20
|
def content_for(name, value = nil, &block)
|
21
|
-
(
|
22
|
-
if block_given?
|
23
|
-
@_content[Thread.current][name] = block
|
24
|
-
elsif value
|
25
|
-
@_content[Thread.current][name] = String.interpolate { value }
|
26
|
-
else
|
27
|
-
@_content[Thread.current][name]
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
def clear_content_for
|
32
|
-
( @_content ||= {} )[Thread.current] ||= {}
|
33
|
-
@_content.delete(Thread.current)
|
21
|
+
RubyApp::Request.content_for(self, name, value, &block)
|
34
22
|
end
|
35
23
|
|
36
24
|
def render(format)
|
@@ -42,9 +30,9 @@ module RubyApp
|
|
42
30
|
templates.each_with_index do |template, index|
|
43
31
|
content = Haml::Engine.new(File.read(template), :filename => template).render(self) do |*arguments|
|
44
32
|
if arguments.empty?
|
45
|
-
index == 0 ? nil :
|
33
|
+
index == 0 ? nil : RubyApp::Request.get_content(self, templates[index - 1])
|
46
34
|
else
|
47
|
-
_content =
|
35
|
+
_content = RubyApp::Request.get_content(self, arguments[0])
|
48
36
|
if self.block_is_haml?(_content)
|
49
37
|
self.capture_haml(arguments, &_content)
|
50
38
|
else
|
@@ -52,11 +40,11 @@ module RubyApp
|
|
52
40
|
end
|
53
41
|
end
|
54
42
|
end
|
55
|
-
|
43
|
+
RubyApp::Request.content_for(self, template, content)
|
56
44
|
end
|
57
|
-
return
|
45
|
+
return RubyApp::Request.get_content(self, templates.last)
|
58
46
|
ensure
|
59
|
-
self
|
47
|
+
RubyApp::Request.clear_content(self)
|
60
48
|
end
|
61
49
|
end
|
62
50
|
|
data/lib/ruby_app/request.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'rubygems'
|
2
2
|
require 'bundler/setup'
|
3
3
|
|
4
|
+
require 'facets/string/interpolate'
|
4
5
|
require 'rack'
|
5
6
|
|
6
7
|
module RubyApp
|
@@ -26,13 +27,34 @@ module RubyApp
|
|
26
27
|
self.params
|
27
28
|
end
|
28
29
|
|
30
|
+
def rendered?(template)
|
31
|
+
@rendered.key?(template)
|
32
|
+
end
|
33
|
+
|
34
|
+
def rendered(template)
|
35
|
+
@rendered[template] = true
|
36
|
+
end
|
37
|
+
|
38
|
+
def content_for(element, name, value = nil, &block)
|
39
|
+
@content[element] ||= {}
|
40
|
+
@content[element][name] = block_given? ? block : String.interpolate { value }
|
41
|
+
end
|
42
|
+
|
43
|
+
def get_content(element, name)
|
44
|
+
@content[element] ||= {}
|
45
|
+
return @content[element][name]
|
46
|
+
end
|
47
|
+
|
48
|
+
def clear_content(element)
|
49
|
+
@content[element] ||= {}
|
50
|
+
end
|
51
|
+
|
29
52
|
def self.get
|
30
53
|
Thread.current[:_request]
|
31
54
|
end
|
32
55
|
|
33
56
|
def self.create!(environment = RubyApp::Application.environment)
|
34
57
|
Thread.current[:_request] = RubyApp::Request.new(environment)
|
35
|
-
Thread.current[:_rendered] = {}
|
36
58
|
|
37
59
|
if block_given?
|
38
60
|
begin
|
@@ -62,7 +84,6 @@ module RubyApp
|
|
62
84
|
end
|
63
85
|
|
64
86
|
def self.destroy!
|
65
|
-
Thread.current[:_rendered] = nil
|
66
87
|
Thread.current[:_request] = nil
|
67
88
|
end
|
68
89
|
|
@@ -70,6 +91,8 @@ module RubyApp
|
|
70
91
|
|
71
92
|
def initialize(environment)
|
72
93
|
super(environment)
|
94
|
+
@rendered = {}
|
95
|
+
@content = {}
|
73
96
|
end
|
74
97
|
|
75
98
|
end
|
data/lib/ruby_app/version.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: RubyApp
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 147
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 70
|
10
|
+
version: 0.0.70
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Frank G. Ficnar
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2012-01-
|
18
|
+
date: 2012-01-18 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
prerelease: false
|