radiant-layouts-extension 1.1.2 → 1.1.3
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/nested_layouts/tags/core.rb +32 -23
- data/radiant-layouts-extension.gemspec +2 -2
- data/spec/lib/nested_layouts/tags/core_spec.rb +37 -5
- metadata +4 -4
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.1.
|
1
|
+
1.1.3
|
@@ -90,32 +90,30 @@ module NestedLayouts
|
|
90
90
|
current_layout_name(tag)
|
91
91
|
end
|
92
92
|
|
93
|
-
desc %{
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
93
|
+
desc %{
|
94
|
+
output the contents of tag if layout equals name (support regex)
|
95
|
+
|
96
|
+
*Usage:*
|
97
|
+
|
98
|
+
<pre><code><r:if_layout name="(parent|parent_of_child)">
|
99
|
+
one of those layouts
|
100
|
+
</r:if_layout></code></pre>
|
101
|
+
}
|
102
|
+
tag 'if_layout' do |tag|
|
103
|
+
tag.expand if is_current_layout(tag)
|
104
104
|
end
|
105
105
|
|
106
|
-
desc %{
|
106
|
+
desc %{
|
107
|
+
Output the contents of tag unless layout equals name (support regex)
|
108
|
+
|
109
|
+
*Usage:*
|
110
|
+
|
111
|
+
<pre><code><r:unless_layout name="parent">
|
112
|
+
not the parent layotu
|
113
|
+
</r:unless_layout></code></pre>
|
114
|
+
}
|
107
115
|
tag 'unless_layout' do |tag|
|
108
|
-
|
109
|
-
if layout = tag.globals.page_original_layout
|
110
|
-
tag.expand if layout.name != name
|
111
|
-
elsif layout = tag.globals.page.layout
|
112
|
-
tag.expand if layout.name != name
|
113
|
-
else
|
114
|
-
tag.expand
|
115
|
-
end
|
116
|
-
else
|
117
|
-
raise TagError.new(%{Error (nested_layouts): "if_layout" tag must contain a "name" attribute})
|
118
|
-
end
|
116
|
+
tag.expand unless is_current_layout(tag)
|
119
117
|
end
|
120
118
|
|
121
119
|
tag 'body' do |tag|
|
@@ -136,6 +134,17 @@ module NestedLayouts
|
|
136
134
|
result
|
137
135
|
end
|
138
136
|
|
137
|
+
def is_current_layout(tag)
|
138
|
+
if tag.attr['name'].nil?
|
139
|
+
raise TagError.new(%{Error (nested_layouts): "if_layout" tag must contain a "name" attribute})
|
140
|
+
end
|
141
|
+
|
142
|
+
layout = tag.globals.page_original_layout || tag.globals.page.layout
|
143
|
+
search = %r{#{tag.attr['name']}}
|
144
|
+
|
145
|
+
(layout.name =~ search).present?
|
146
|
+
end
|
147
|
+
|
139
148
|
end
|
140
149
|
end
|
141
150
|
end
|
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{radiant-layouts-extension}
|
8
|
-
s.version = "1.1.
|
8
|
+
s.version = "1.1.3"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Michael Klett", "Jim Gay", "William Ross", "Tony Issakov", "Dirk Kelly"]
|
12
|
-
s.date = %q{2010-12-
|
12
|
+
s.date = %q{2010-12-13}
|
13
13
|
s.description = %q{Extends Radiant Layouts to support nesting, sharing with Rails Controllers and rendering HAML}
|
14
14
|
s.email = %q{dk@dirkkelly.com}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -58,6 +58,22 @@ CONTENT
|
|
58
58
|
pages(:parent).should render(tag).as(expected)
|
59
59
|
end
|
60
60
|
|
61
|
+
it 'it should support regex' do
|
62
|
+
tag = %{<r:inside_layout name='parent'><r:if_layout name='(parent|child)'><h1>Hi</h1></r:if_layout></r:inside_layout>}
|
63
|
+
expected = <<-CONTENT
|
64
|
+
<!DOCTYPE html>
|
65
|
+
<html>
|
66
|
+
<head>
|
67
|
+
<title>Title</title>
|
68
|
+
</head>
|
69
|
+
<body id="" class="parent site">
|
70
|
+
<h1>Hi</h1>
|
71
|
+
</body>
|
72
|
+
</html>
|
73
|
+
CONTENT
|
74
|
+
pages(:parent).should render(tag).as(expected)
|
75
|
+
end
|
76
|
+
|
61
77
|
it 'it should not render the contents if false' do
|
62
78
|
tag = %{<r:inside_layout name='parent'><r:if_layout name='not parent'><h1>Hi</h1></r:if_layout></r:inside_layout>}
|
63
79
|
expected = <<-CONTENT
|
@@ -78,8 +94,8 @@ CONTENT
|
|
78
94
|
|
79
95
|
describe '<r:unless_layout>' do
|
80
96
|
|
81
|
-
it 'it should not render the contents if
|
82
|
-
tag = %{<r:inside_layout name='parent'><r:unless_layout name='parent'><h1>Hi</h1></r:unless_layout></r:inside_layout>}
|
97
|
+
it 'it should not render the contents if false' do
|
98
|
+
tag = %{<r:inside_layout name='parent'><r:unless_layout name='not parent'><h1>Hi</h1></r:unless_layout></r:inside_layout>}
|
83
99
|
expected = <<-CONTENT
|
84
100
|
<!DOCTYPE html>
|
85
101
|
<html>
|
@@ -87,15 +103,31 @@ CONTENT
|
|
87
103
|
<title>Title</title>
|
88
104
|
</head>
|
89
105
|
<body id="" class="parent site">
|
106
|
+
<h1>Hi</h1>
|
107
|
+
</body>
|
108
|
+
</html>
|
109
|
+
CONTENT
|
110
|
+
pages(:parent).should render(tag).as(expected)
|
111
|
+
end
|
90
112
|
|
113
|
+
it 'it should support regex' do
|
114
|
+
tag = %{<r:inside_layout name='parent'><r:unless_layout name='(not_parent|not_child)'><h1>Hi</h1></r:unless_layout></r:inside_layout>}
|
115
|
+
expected = <<-CONTENT
|
116
|
+
<!DOCTYPE html>
|
117
|
+
<html>
|
118
|
+
<head>
|
119
|
+
<title>Title</title>
|
120
|
+
</head>
|
121
|
+
<body id="" class="parent site">
|
122
|
+
<h1>Hi</h1>
|
91
123
|
</body>
|
92
124
|
</html>
|
93
125
|
CONTENT
|
94
126
|
pages(:parent).should render(tag).as(expected)
|
95
127
|
end
|
96
128
|
|
97
|
-
it 'it should not render the contents if
|
98
|
-
tag = %{<r:inside_layout name='parent'><r:unless_layout name='
|
129
|
+
it 'it should not render the contents if true' do
|
130
|
+
tag = %{<r:inside_layout name='parent'><r:unless_layout name='parent'><h1>Hi</h1></r:unless_layout></r:inside_layout>}
|
99
131
|
expected = <<-CONTENT
|
100
132
|
<!DOCTYPE html>
|
101
133
|
<html>
|
@@ -103,7 +135,7 @@ CONTENT
|
|
103
135
|
<title>Title</title>
|
104
136
|
</head>
|
105
137
|
<body id="" class="parent site">
|
106
|
-
|
138
|
+
|
107
139
|
</body>
|
108
140
|
</html>
|
109
141
|
CONTENT
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: radiant-layouts-extension
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 21
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 1.1.
|
9
|
+
- 3
|
10
|
+
version: 1.1.3
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Michael Klett
|
@@ -19,7 +19,7 @@ autorequire:
|
|
19
19
|
bindir: bin
|
20
20
|
cert_chain: []
|
21
21
|
|
22
|
-
date: 2010-12-
|
22
|
+
date: 2010-12-13 00:00:00 +08:00
|
23
23
|
default_executable:
|
24
24
|
dependencies:
|
25
25
|
- !ruby/object:Gem::Dependency
|