template-inheritance 0.3 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -23,6 +23,8 @@ class Foo & Padrino::Application
23
23
  end
24
24
  </pre>
25
25
 
26
+ Also if you are on Padrino Git HEAD or Padrino 0.9.29, you have to set @SKIP_PADRINO_RENDERING@ to @true@ _before Padrino is loaded_. It's because of a "bug in Padrino":https://github.com/padrino/padrino-framework/issues/541.
27
+
26
28
  h1. Haml Extensions
27
29
 
28
30
  <pre>
@@ -1,5 +1,6 @@
1
1
  # encoding: utf-8
2
2
 
3
+ require "haml"
3
4
  require "template-inheritance/exts/tilt"
4
5
  require "template-inheritance/helpers"
5
6
 
@@ -93,13 +94,7 @@ module TemplateInheritance
93
94
  self.scope.context = self.context = context # so we can access context in the scope object as well
94
95
  value = self.template.render(self.scope, context)
95
96
  TemplateInheritance.logger.debug("Available blocks: #{self.blocks.keys.inspect}")
96
- if self.supertemplate
97
- TemplateInheritance.logger.debug("Extends call: #{self.supertemplate}")
98
- supertemplate = self.class.new(self.supertemplate, self.scope)
99
- supertemplate.blocks = self.blocks
100
- return supertemplate.render(context)
101
- end
102
- value
97
+ self.supertemplate ? render_supertemplate : value
103
98
  end
104
99
 
105
100
  protected
@@ -114,6 +109,18 @@ module TemplateInheritance
114
109
  end
115
110
  end
116
111
 
112
+ def instantiate_supertemplate
113
+ supertemplate = self.class.new(self.supertemplate, self.scope)
114
+ supertemplate.blocks = self.blocks
115
+ supertemplate
116
+ end
117
+
118
+ def render_supertemplate
119
+ TemplateInheritance.logger.debug("Extends call: #{self.supertemplate}")
120
+ supertemplate = instantiate_supertemplate
121
+ return supertemplate.render(context)
122
+ end
123
+
117
124
  def find_file(one, other)
118
125
  alternatives = Dir[one, other]
119
126
  alternatives.find { |file| File.file?(file) }
@@ -7,6 +7,13 @@ require "padrino-core/application/rendering"
7
7
  module TemplateInheritance
8
8
  class Template
9
9
  attr_accessor :padrino_views_directory
10
+
11
+ def instantiate_supertemplate
12
+ supertemplate = self.class.new(self.supertemplate, self.scope)
13
+ supertemplate.padrino_views_directory = self.padrino_views_directory
14
+ supertemplate.blocks = self.blocks
15
+ supertemplate
16
+ end
10
17
  end
11
18
 
12
19
  module TemplateHelpers
@@ -25,8 +32,9 @@ module TemplateInheritance::Rendering
25
32
  end
26
33
 
27
34
  # TODO: support options for Haml.
28
- # NOTE: block does nothing.
35
+ # NOTE: block does nothing, it's for builder etc, not useful for Haml.
29
36
  # FIXME: locals doesn't work because we don't get them from Padrino.
37
+ # TODO: no support for render(_, data) i. e. render { :a => 1, :b => 2, :c => 3 }
30
38
  include Module.new {
31
39
  def render(_, path, options, locals, &block)
32
40
  base_dir = options[:views] || settings.views || "./views"
@@ -5,12 +5,11 @@ require "base64"
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "template-inheritance"
8
- s.version = "0.3"
8
+ s.version = "0.3.1"
9
9
  s.authors = ["Jakub Šťastný aka Botanicus"]
10
10
  s.homepage = "http://github.com/botanicus/template-inheritance"
11
11
  s.summary = ""
12
12
  s.description = "" # TODO: long description
13
- s.cert_chain = nil
14
13
  s.email = Base64.decode64("c3Rhc3RueUAxMDFpZGVhcy5jeg==\n")
15
14
  s.has_rdoc = true
16
15
 
@@ -19,12 +18,6 @@ Gem::Specification.new do |s|
19
18
 
20
19
  s.require_paths = ["lib"]
21
20
 
22
- # Ruby version
23
- # Current JRuby with --1.9 switch has RUBY_VERSION set to "1.9.2dev"
24
- # and RubyGems don't play well with it, so we have to set minimal
25
- # Ruby version to 1.9, even if it actually is 1.9.1
26
- s.required_ruby_version = ::Gem::Requirement.new("~> 1.9")
27
-
28
21
  # dependencies
29
22
  s.add_dependency "tilt"
30
23
  s.add_dependency "haml"
metadata CHANGED
@@ -1,48 +1,55 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: template-inheritance
3
- version: !ruby/object:Gem::Version
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.3.1
4
5
  prerelease:
5
- version: "0.3"
6
6
  platform: ruby
7
- authors:
8
- - "Jakub \xC5\xA0\xC5\xA5astn\xC3\xBD aka Botanicus"
7
+ authors:
8
+ - Jakub Šťastný aka Botanicus
9
9
  autorequire:
10
10
  bindir: bin
11
- cert_chain:
12
- date: 2011-05-19 00:00:00 +02:00
13
- default_executable:
14
- dependencies:
15
- - !ruby/object:Gem::Dependency
11
+ cert_chain: []
12
+ date: 2013-04-26 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
16
15
  name: tilt
17
- prerelease: false
18
- requirement: &id001 !ruby/object:Gem::Requirement
16
+ requirement: !ruby/object:Gem::Requirement
19
17
  none: false
20
- requirements:
21
- - - ">="
22
- - !ruby/object:Gem::Version
23
- version: "0"
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
24
22
  type: :runtime
25
- version_requirements: *id001
26
- - !ruby/object:Gem::Dependency
27
- name: haml
28
23
  prerelease: false
29
- requirement: &id002 !ruby/object:Gem::Requirement
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: haml
32
+ requirement: !ruby/object:Gem::Requirement
30
33
  none: false
31
- requirements:
32
- - - ">="
33
- - !ruby/object:Gem::Version
34
- version: "0"
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
35
38
  type: :runtime
36
- version_requirements: *id002
37
- description: ""
38
- email: stastny@101ideas.cz
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ description: ''
47
+ email: !binary |-
48
+ c3Rhc3RueUAxMDFpZGVhcy5jeg==
39
49
  executables: []
40
-
41
50
  extensions: []
42
-
43
51
  extra_rdoc_files: []
44
-
45
- files:
52
+ files:
46
53
  - .gitignore
47
54
  - README.textile
48
55
  - example/base.html.haml
@@ -92,33 +99,28 @@ files:
92
99
  - spec/templates/helpers_spec.rb
93
100
  - spec/templates/template_spec.rb
94
101
  - template-inheritance.gemspec
95
- has_rdoc: true
96
102
  homepage: http://github.com/botanicus/template-inheritance
97
103
  licenses: []
98
-
99
104
  post_install_message:
100
105
  rdoc_options: []
101
-
102
- require_paths:
106
+ require_paths:
103
107
  - lib
104
- required_ruby_version: !ruby/object:Gem::Requirement
108
+ required_ruby_version: !ruby/object:Gem::Requirement
105
109
  none: false
106
- requirements:
107
- - - ~>
108
- - !ruby/object:Gem::Version
109
- version: "1.9"
110
- required_rubygems_version: !ruby/object:Gem::Requirement
110
+ requirements:
111
+ - - ! '>='
112
+ - !ruby/object:Gem::Version
113
+ version: '0'
114
+ required_rubygems_version: !ruby/object:Gem::Requirement
111
115
  none: false
112
- requirements:
113
- - - ">="
114
- - !ruby/object:Gem::Version
115
- version: "0"
116
+ requirements:
117
+ - - ! '>='
118
+ - !ruby/object:Gem::Version
119
+ version: '0'
116
120
  requirements: []
117
-
118
121
  rubyforge_project: template-inheritance
119
- rubygems_version: 1.5.3
122
+ rubygems_version: 1.8.23
120
123
  signing_key:
121
124
  specification_version: 3
122
- summary: ""
125
+ summary: ''
123
126
  test_files: []
124
-