radiant-layouts-extension 0.9.1 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/MIT-LICENSE +75 -4
- data/README.md +48 -1
- data/Rakefile +56 -15
- data/VERSION +1 -1
- data/app/models/haml_filter.rb +5 -0
- data/app/views/layouts/radiant.html.haml +1 -1
- data/config/routes.rb +5 -0
- data/layouts_extension.rb +13 -5
- data/lib/haml_layouts/models/layout.rb +34 -0
- data/lib/haml_layouts/models/page.rb +31 -0
- data/lib/nested_layouts/tags/core.rb +141 -0
- data/lib/share_layouts/controllers/action_controller.rb +25 -0
- data/lib/share_layouts/helpers/action_view.rb +50 -0
- data/lib/tasks/layouts_extension_tasks.rake +27 -6
- data/radiant-layouts-extension.gemspec +37 -26
- data/spec/controllers/{share_layouts_spec.rb → share_controller_spec.rb} +0 -0
- data/spec/datasets/layouts_layouts.rb +36 -0
- data/spec/datasets/layouts_pages.rb +43 -0
- data/spec/lib/haml_layouts/haml_layouts_extension_spec.rb +22 -0
- data/spec/lib/haml_layouts/models/layout_spec.rb +36 -0
- data/spec/lib/haml_layouts/models/page_spec.rb +40 -0
- data/spec/lib/nested_layouts/nested_layouts_extension_spec.rb +16 -0
- data/spec/lib/nested_layouts/{tags_spec.rb → tags/core_spec.rb} +41 -17
- data/spec/{controllers/nested_layouts_spec.rb → lib/share_layouts/controllers/action_controller_spec.rb} +0 -1
- data/spec/{helpers/share_layouts_helper_spec.rb → lib/share_layouts/helpers/action_view_spec.rb} +32 -29
- data/spec/lib/share_layouts/share_layouts_extension_spec.rb +22 -0
- data/spec/models/haml_filter_spec.rb +0 -0
- data/spec/models/rails_page_spec.rb +9 -9
- data/spec/spec.opts +2 -3
- metadata +43 -28
- data/lib/nested_layouts.rb +0 -2
- data/lib/nested_layouts/tags.rb +0 -127
- data/lib/share_layouts.rb +0 -2
- data/lib/share_layouts/helper.rb +0 -39
- data/lib/share_layouts/radiant_layouts.rb +0 -21
- data/spec/datasets/nested_layouts_dataset.rb +0 -38
- data/spec/datasets/share_layouts_dataset.rb +0 -38
- data/spec/lib/share_layouts_extension_spec.rb +0 -25
- data/spec/rcov.opts +0 -2
@@ -0,0 +1,25 @@
|
|
1
|
+
module ShareLayouts
|
2
|
+
module Controllers
|
3
|
+
module ActionController
|
4
|
+
|
5
|
+
def self.included(base)
|
6
|
+
base.extend ClassMethods
|
7
|
+
end
|
8
|
+
|
9
|
+
module ClassMethods
|
10
|
+
def radiant_layout(name=nil, options={}, &block)
|
11
|
+
raise ArgumentError, "A layout name or block is required!" unless name || block
|
12
|
+
write_inheritable_attribute 'radiant_layout', name || block
|
13
|
+
before_filter :set_radiant_layout
|
14
|
+
layout 'radiant', options
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def set_radiant_layout
|
19
|
+
@radiant_layout = self.class.read_inheritable_attribute 'radiant_layout'
|
20
|
+
@radiant_layout = @radiant_layout.call(self) if @radiant_layout.is_a? Proc
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
module ShareLayouts
|
2
|
+
module Helpers
|
3
|
+
module ActionView
|
4
|
+
|
5
|
+
def self.included(base)
|
6
|
+
base.class_eval do
|
7
|
+
|
8
|
+
def radiant_layout(name = @radiant_layout)
|
9
|
+
page = find_page
|
10
|
+
assign_attributes!(page, name)
|
11
|
+
page.build_parts_from_hash!(extract_captures)
|
12
|
+
page.render
|
13
|
+
end
|
14
|
+
|
15
|
+
def assign_attributes!(page, name = @radiant_layout)
|
16
|
+
page.layout = Layout.find_by_name(name) || page.layout
|
17
|
+
page.title = @title || @content_for_title || page.title || ''
|
18
|
+
page.breadcrumb = @breadcrumb || @content_for_breadcrumb || page.breadcrumb || page.title
|
19
|
+
page.breadcrumbs = @breadcrumbs || @content_for_breadcrumbs || nil
|
20
|
+
page.url = request.path
|
21
|
+
page.slug = page.url.split("/").last
|
22
|
+
page.published_at ||= Time.now
|
23
|
+
page.request = request
|
24
|
+
page.response = response
|
25
|
+
end
|
26
|
+
|
27
|
+
def extract_captures
|
28
|
+
variables = instance_variables.grep(/@content_for_/)
|
29
|
+
variables.inject({}) do |h, var|
|
30
|
+
var =~ /^@content_for_(.*)$/
|
31
|
+
key = $1.intern
|
32
|
+
key = :body if key == :layout
|
33
|
+
unless key == :title || key == :breadcrumbs
|
34
|
+
h[key] = instance_variable_get(var)
|
35
|
+
end
|
36
|
+
h
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def find_page
|
41
|
+
page = Page.find_by_url(request.path) rescue nil
|
42
|
+
page.is_a?(RailsPage) ? page : RailsPage.new(:class_name => "RailsPage")
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -2,15 +2,37 @@ namespace :radiant do
|
|
2
2
|
namespace :extensions do
|
3
3
|
namespace :layouts do
|
4
4
|
|
5
|
-
desc "Runs the migration of the
|
5
|
+
desc "Runs the migration of the Layouts extension"
|
6
6
|
task :migrate => :environment do
|
7
|
-
|
7
|
+
require 'radiant/extension_migrator'
|
8
|
+
if ENV["VERSION"]
|
9
|
+
LayoutsExtension.migrator.migrate(ENV["VERSION"].to_i)
|
10
|
+
Rake::Task['db:schema:dump'].invoke
|
11
|
+
else
|
12
|
+
LayoutsExtension.migrator.migrate
|
13
|
+
Rake::Task['db:schema:dump'].invoke
|
14
|
+
end
|
8
15
|
end
|
9
16
|
|
10
|
-
desc "Copies public assets of the
|
17
|
+
desc "Copies public assets of the Layouts to the instance public/ directory."
|
11
18
|
task :update => :environment do
|
12
|
-
|
13
|
-
|
19
|
+
is_svn_or_dir = proc {|path| path =~ /\.svn/ || File.directory?(path) }
|
20
|
+
puts "Copying assets from LayoutsExtension"
|
21
|
+
Dir[LayoutsExtension.root + "/public/**/*"].reject(&is_svn_or_dir).each do |file|
|
22
|
+
path = file.sub(LayoutsExtension.root, '')
|
23
|
+
directory = File.dirname(path)
|
24
|
+
mkdir_p RAILS_ROOT + directory, :verbose => false
|
25
|
+
cp file, RAILS_ROOT + path, :verbose => false
|
26
|
+
end
|
27
|
+
unless LayoutsExtension.root.starts_with? RAILS_ROOT # don't need to copy vendored tasks
|
28
|
+
puts "Copying rake tasks from LayoutsExtension"
|
29
|
+
local_tasks_path = File.join(RAILS_ROOT, %w(lib tasks))
|
30
|
+
mkdir_p local_tasks_path, :verbose => false
|
31
|
+
Dir[File.join LayoutsExtension.root, %w(lib tasks *.rake)].each do |file|
|
32
|
+
cp file, local_tasks_path, :verbose => false
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
14
36
|
|
15
37
|
desc "Syncs all available translations for this ext to the English ext master"
|
16
38
|
task :sync => :environment do
|
@@ -28,7 +50,6 @@ namespace :radiant do
|
|
28
50
|
TranslationSupport.write_file(filename, basename, comments, other)
|
29
51
|
end
|
30
52
|
end
|
31
|
-
|
32
53
|
end
|
33
54
|
end
|
34
55
|
end
|
@@ -5,13 +5,13 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{radiant-layouts-extension}
|
8
|
-
s.version = "0.
|
8
|
+
s.version = "1.0.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
-
s.authors = ["Dirk Kelly"]
|
12
|
-
s.date = %q{2010-
|
13
|
-
s.description = %q{
|
14
|
-
s.email = %q{dk@
|
11
|
+
s.authors = ["Michael Klett", "Jim Gay", "William Ross", "Tony Issakov", "Dirk Kelly"]
|
12
|
+
s.date = %q{2010-10-20}
|
13
|
+
s.description = %q{Extends Radiant Layouts to support nesting, sharing with Rails Controllers and rendering HAML}
|
14
|
+
s.email = %q{dk@dirkkelly.com}
|
15
15
|
s.extra_rdoc_files = [
|
16
16
|
"README.md"
|
17
17
|
]
|
@@ -21,25 +21,31 @@ Gem::Specification.new do |s|
|
|
21
21
|
"README.md",
|
22
22
|
"Rakefile",
|
23
23
|
"VERSION",
|
24
|
+
"app/models/haml_filter.rb",
|
24
25
|
"app/models/rails_page.rb",
|
25
26
|
"app/views/layouts/radiant.html.haml",
|
27
|
+
"config/routes.rb",
|
26
28
|
"layouts_extension.rb",
|
27
|
-
"lib/
|
28
|
-
"lib/
|
29
|
-
"lib/
|
30
|
-
"lib/share_layouts/
|
31
|
-
"lib/share_layouts/
|
29
|
+
"lib/haml_layouts/models/layout.rb",
|
30
|
+
"lib/haml_layouts/models/page.rb",
|
31
|
+
"lib/nested_layouts/tags/core.rb",
|
32
|
+
"lib/share_layouts/controllers/action_controller.rb",
|
33
|
+
"lib/share_layouts/helpers/action_view.rb",
|
32
34
|
"lib/tasks/layouts_extension_tasks.rake",
|
33
35
|
"radiant-layouts-extension.gemspec",
|
34
|
-
"spec/controllers/
|
35
|
-
"spec/
|
36
|
-
"spec/datasets/
|
37
|
-
"spec/
|
38
|
-
"spec/
|
39
|
-
"spec/lib/
|
40
|
-
"spec/lib/
|
36
|
+
"spec/controllers/share_controller_spec.rb",
|
37
|
+
"spec/datasets/layouts_layouts.rb",
|
38
|
+
"spec/datasets/layouts_pages.rb",
|
39
|
+
"spec/lib/haml_layouts/haml_layouts_extension_spec.rb",
|
40
|
+
"spec/lib/haml_layouts/models/layout_spec.rb",
|
41
|
+
"spec/lib/haml_layouts/models/page_spec.rb",
|
42
|
+
"spec/lib/nested_layouts/nested_layouts_extension_spec.rb",
|
43
|
+
"spec/lib/nested_layouts/tags/core_spec.rb",
|
44
|
+
"spec/lib/share_layouts/controllers/action_controller_spec.rb",
|
45
|
+
"spec/lib/share_layouts/helpers/action_view_spec.rb",
|
46
|
+
"spec/lib/share_layouts/share_layouts_extension_spec.rb",
|
47
|
+
"spec/models/haml_filter_spec.rb",
|
41
48
|
"spec/models/rails_page_spec.rb",
|
42
|
-
"spec/rcov.opts",
|
43
49
|
"spec/spec.opts",
|
44
50
|
"spec/spec_helper.rb"
|
45
51
|
]
|
@@ -47,15 +53,20 @@ Gem::Specification.new do |s|
|
|
47
53
|
s.rdoc_options = ["--charset=UTF-8"]
|
48
54
|
s.require_paths = ["lib"]
|
49
55
|
s.rubygems_version = %q{1.3.7}
|
50
|
-
s.summary = %q{
|
56
|
+
s.summary = %q{Extends Radiant Layouts to support nesting, sharing with Rails Controllers and rendering HAML}
|
51
57
|
s.test_files = [
|
52
|
-
"spec/controllers/
|
53
|
-
"spec/
|
54
|
-
"spec/datasets/
|
55
|
-
"spec/
|
56
|
-
"spec/
|
57
|
-
"spec/lib/
|
58
|
-
"spec/lib/
|
58
|
+
"spec/controllers/share_controller_spec.rb",
|
59
|
+
"spec/datasets/layouts_layouts.rb",
|
60
|
+
"spec/datasets/layouts_pages.rb",
|
61
|
+
"spec/lib/haml_layouts/haml_layouts_extension_spec.rb",
|
62
|
+
"spec/lib/haml_layouts/models/layout_spec.rb",
|
63
|
+
"spec/lib/haml_layouts/models/page_spec.rb",
|
64
|
+
"spec/lib/nested_layouts/nested_layouts_extension_spec.rb",
|
65
|
+
"spec/lib/nested_layouts/tags/core_spec.rb",
|
66
|
+
"spec/lib/share_layouts/controllers/action_controller_spec.rb",
|
67
|
+
"spec/lib/share_layouts/helpers/action_view_spec.rb",
|
68
|
+
"spec/lib/share_layouts/share_layouts_extension_spec.rb",
|
69
|
+
"spec/models/haml_filter_spec.rb",
|
59
70
|
"spec/models/rails_page_spec.rb",
|
60
71
|
"spec/spec_helper.rb"
|
61
72
|
]
|
File without changes
|
@@ -0,0 +1,36 @@
|
|
1
|
+
class LayoutsLayoutsDataset < Dataset::Base
|
2
|
+
|
3
|
+
def load
|
4
|
+
create_record :layout, :parent,
|
5
|
+
:name => 'parent',
|
6
|
+
:content_type => 'haml',
|
7
|
+
:content => <<-CONTENT
|
8
|
+
!!! 5
|
9
|
+
%html
|
10
|
+
%head
|
11
|
+
%title Title
|
12
|
+
:plain
|
13
|
+
<r:body class="site">
|
14
|
+
<r:content_for_layout />
|
15
|
+
</r:body>
|
16
|
+
CONTENT
|
17
|
+
|
18
|
+
create_record :layout, :child,
|
19
|
+
:name => 'child',
|
20
|
+
:content => <<-CONTENT
|
21
|
+
<r:inside_layout name='parent'>
|
22
|
+
<h1><r:layout /></h1>
|
23
|
+
</r:inside_layout>
|
24
|
+
CONTENT
|
25
|
+
|
26
|
+
create_record :layout, :haml,
|
27
|
+
:name => 'haml',
|
28
|
+
:content_type => 'haml',
|
29
|
+
:content => <<-CONTENT
|
30
|
+
%r:inside_layout{:name=>"parent"}
|
31
|
+
%h1
|
32
|
+
%r:layout
|
33
|
+
CONTENT
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
class LayoutsPagesDataset < Dataset::Base
|
2
|
+
|
3
|
+
uses :layouts_layouts
|
4
|
+
|
5
|
+
def load
|
6
|
+
create_record :page, :parent,
|
7
|
+
:title => 'Parent',
|
8
|
+
:layout_id => layouts(:parent).id,
|
9
|
+
:breadcrumb => 'parent',
|
10
|
+
:slug => '/',
|
11
|
+
:status_id => 100
|
12
|
+
|
13
|
+
create_record :page, :child,
|
14
|
+
:title => 'Child',
|
15
|
+
:layout_id => layouts(:child).id,
|
16
|
+
:parent_id => pages(:parent).id,
|
17
|
+
:breadcrumb => 'child',
|
18
|
+
:slug => '/child',
|
19
|
+
:status_id => 100
|
20
|
+
|
21
|
+
create_record :page, :rails,
|
22
|
+
:title => 'App page',
|
23
|
+
:breadcrumb => 'App page',
|
24
|
+
:slug => 'app',
|
25
|
+
:class_name => 'RailsPage',
|
26
|
+
:status_id => 100,
|
27
|
+
:parent_id => pages(:parent).id
|
28
|
+
|
29
|
+
create_record :page, :rails_child,
|
30
|
+
:title => 'Child',
|
31
|
+
:breadcrumb => 'Child',
|
32
|
+
:slug => 'child-page',
|
33
|
+
:status_id => 100,
|
34
|
+
:parent_id => pages(:rails).id
|
35
|
+
|
36
|
+
create_record :page, :other,
|
37
|
+
:title => 'Other',
|
38
|
+
:breadcrumb => 'Other',
|
39
|
+
:slug => 'other',
|
40
|
+
:status_id => 100,
|
41
|
+
:parent_id => pages(:parent).id
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'spec/spec_helper'
|
2
|
+
|
3
|
+
# Ensures that the Extension initializes correctly
|
4
|
+
describe LayoutsExtension do
|
5
|
+
|
6
|
+
context 'activate' do
|
7
|
+
|
8
|
+
describe 'haml layouts' do
|
9
|
+
it 'should have a HamlFilter class to call' do
|
10
|
+
HamlFilter.should_not be_nil
|
11
|
+
end
|
12
|
+
it 'should extend Layout base methods' do
|
13
|
+
Layout.included_modules.include?(HamlLayouts::Models::Layout).should be_true
|
14
|
+
end
|
15
|
+
it 'should extend Page base methods' do
|
16
|
+
Page.included_modules.include?(HamlLayouts::Models::Page).should be_true
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'spec/spec_helper'
|
2
|
+
|
3
|
+
describe HamlLayouts::Models::Layout do
|
4
|
+
|
5
|
+
dataset :layouts_layouts, :layouts_pages
|
6
|
+
|
7
|
+
describe 'content' do
|
8
|
+
context 'a haml layout' do
|
9
|
+
it 'should return html rendered' do
|
10
|
+
expected = <<-CONTENT
|
11
|
+
<r:inside_layout name='parent'>
|
12
|
+
<h1>
|
13
|
+
<r:layout></r:layout>
|
14
|
+
</h1>
|
15
|
+
</r:inside_layout>
|
16
|
+
CONTENT
|
17
|
+
layouts(:haml).content.should === expected
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
describe 'is_haml?' do
|
23
|
+
context 'layout has a content type of haml' do
|
24
|
+
it 'should return true' do
|
25
|
+
layouts(:haml).is_haml?.should be_true
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
context 'layout does not have a content type of haml' do
|
30
|
+
it 'should return false' do
|
31
|
+
layouts(:child).is_haml?.should be_false
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require 'spec/spec_helper'
|
2
|
+
|
3
|
+
describe HamlLayouts::Models::Page do
|
4
|
+
|
5
|
+
dataset :layouts_layouts, :layouts_pages
|
6
|
+
|
7
|
+
describe 'parse_object' do
|
8
|
+
context 'haml filter type' do
|
9
|
+
it 'should render haml radius tags' do
|
10
|
+
@part = PagePart.new({
|
11
|
+
:content => '%r:title',
|
12
|
+
:filter_id => 'Haml'
|
13
|
+
})
|
14
|
+
@page = pages(:parent)
|
15
|
+
|
16
|
+
@page.parse_object(@part).should === "#{@page.title}\n"
|
17
|
+
end
|
18
|
+
|
19
|
+
it 'should render textile radius tags' do
|
20
|
+
@part = PagePart.new({
|
21
|
+
:content => 'h1. <r:title />',
|
22
|
+
:filter_id => 'Textile'
|
23
|
+
})
|
24
|
+
@page = pages(:parent)
|
25
|
+
|
26
|
+
@page.parse_object(@part).should === "<h1>#{@page.title}</h1>"
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'should render non filtered tags' do
|
30
|
+
@part = PagePart.new({
|
31
|
+
:content => '<r:title />'
|
32
|
+
})
|
33
|
+
@page = pages(:parent)
|
34
|
+
|
35
|
+
@page.parse_object(@part).should === @page.title
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'spec/spec_helper'
|
2
|
+
|
3
|
+
# Ensures that the Extension initializes correctly
|
4
|
+
describe LayoutsExtension do
|
5
|
+
|
6
|
+
context 'activate' do
|
7
|
+
|
8
|
+
describe 'nested layouts' do
|
9
|
+
it 'should extend Page base methods' do
|
10
|
+
Page.included_modules.include?(NestedLayouts::Tags::Core).should be_true
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
@@ -1,33 +1,41 @@
|
|
1
|
-
require
|
1
|
+
require 'spec/spec_helper'
|
2
2
|
|
3
|
-
describe NestedLayouts::Tags do
|
4
|
-
dataset :pages
|
5
|
-
dataset :nested_layouts
|
3
|
+
describe NestedLayouts::Tags::Core do
|
6
4
|
|
7
|
-
|
5
|
+
dataset :layouts_pages, :layouts_layouts
|
6
|
+
|
7
|
+
describe '<r:inside_layout>, <r:layout>, <r:body /> and <r:content_for_layout>' do
|
8
8
|
|
9
9
|
it 'should output tag within the body of class name for parent layout' do
|
10
10
|
tag = %{<r:inside_layout name='parent'><h1>Hi</h1></r:inside_layout>}
|
11
11
|
expected = <<-CONTENT
|
12
|
+
<!DOCTYPE html>
|
12
13
|
<html>
|
13
|
-
<
|
14
|
+
<head>
|
15
|
+
<title>Title</title>
|
16
|
+
</head>
|
17
|
+
<body class="site parent">
|
14
18
|
<h1>Hi</h1>
|
15
19
|
</body>
|
16
20
|
</html>
|
17
21
|
CONTENT
|
18
|
-
pages(:
|
22
|
+
pages(:parent).should render(tag).as(expected)
|
19
23
|
end
|
20
24
|
|
21
25
|
it 'should output tag within the body of class name for a child_layout' do
|
22
26
|
tag = %{<r:inside_layout name='parent'><h1>Hi</h1></r:inside_layout>}
|
23
27
|
expected = <<-CONTENT
|
28
|
+
<!DOCTYPE html>
|
24
29
|
<html>
|
25
|
-
<
|
30
|
+
<head>
|
31
|
+
<title>Title</title>
|
32
|
+
</head>
|
33
|
+
<body class="site child">
|
26
34
|
<h1>Hi</h1>
|
27
35
|
</body>
|
28
36
|
</html>
|
29
37
|
CONTENT
|
30
|
-
pages(:
|
38
|
+
pages(:child).should render(tag).as(expected)
|
31
39
|
end
|
32
40
|
|
33
41
|
end
|
@@ -37,25 +45,33 @@ CONTENT
|
|
37
45
|
it 'it should render the contents if true' do
|
38
46
|
tag = %{<r:inside_layout name='parent'><r:if_layout name='parent'><h1>Hi</h1></r:if_layout></r:inside_layout>}
|
39
47
|
expected = <<-CONTENT
|
48
|
+
<!DOCTYPE html>
|
40
49
|
<html>
|
41
|
-
<
|
50
|
+
<head>
|
51
|
+
<title>Title</title>
|
52
|
+
</head>
|
53
|
+
<body class="site parent">
|
42
54
|
<h1>Hi</h1>
|
43
55
|
</body>
|
44
56
|
</html>
|
45
57
|
CONTENT
|
46
|
-
pages(:
|
58
|
+
pages(:parent).should render(tag).as(expected)
|
47
59
|
end
|
48
60
|
|
49
61
|
it 'it should not render the contents if false' do
|
50
62
|
tag = %{<r:inside_layout name='parent'><r:if_layout name='not parent'><h1>Hi</h1></r:if_layout></r:inside_layout>}
|
51
63
|
expected = <<-CONTENT
|
64
|
+
<!DOCTYPE html>
|
52
65
|
<html>
|
53
|
-
<
|
66
|
+
<head>
|
67
|
+
<title>Title</title>
|
68
|
+
</head>
|
69
|
+
<body class="site parent">
|
54
70
|
|
55
71
|
</body>
|
56
72
|
</html>
|
57
73
|
CONTENT
|
58
|
-
pages(:
|
74
|
+
pages(:parent).should render(tag).as(expected)
|
59
75
|
end
|
60
76
|
|
61
77
|
end
|
@@ -65,25 +81,33 @@ CONTENT
|
|
65
81
|
it 'it should not render the contents if true' do
|
66
82
|
tag = %{<r:inside_layout name='parent'><r:unless_layout name='parent'><h1>Hi</h1></r:unless_layout></r:inside_layout>}
|
67
83
|
expected = <<-CONTENT
|
84
|
+
<!DOCTYPE html>
|
68
85
|
<html>
|
69
|
-
<
|
86
|
+
<head>
|
87
|
+
<title>Title</title>
|
88
|
+
</head>
|
89
|
+
<body class="site parent">
|
70
90
|
|
71
91
|
</body>
|
72
92
|
</html>
|
73
93
|
CONTENT
|
74
|
-
pages(:
|
94
|
+
pages(:parent).should render(tag).as(expected)
|
75
95
|
end
|
76
96
|
|
77
97
|
it 'it should not render the contents if false' do
|
78
98
|
tag = %{<r:inside_layout name='parent'><r:unless_layout name='not parent'><h1>Hi</h1></r:unless_layout></r:inside_layout>}
|
79
99
|
expected = <<-CONTENT
|
100
|
+
<!DOCTYPE html>
|
80
101
|
<html>
|
81
|
-
<
|
102
|
+
<head>
|
103
|
+
<title>Title</title>
|
104
|
+
</head>
|
105
|
+
<body class="site parent">
|
82
106
|
<h1>Hi</h1>
|
83
107
|
</body>
|
84
108
|
</html>
|
85
109
|
CONTENT
|
86
|
-
pages(:
|
110
|
+
pages(:parent).should render(tag).as(expected)
|
87
111
|
end
|
88
112
|
|
89
113
|
end
|