rango 0.1.1.2.10 → 0.1.1.2.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (66) hide show
  1. data/CHANGELOG +7 -0
  2. data/README.textile +2 -0
  3. data/bin/rango +5 -2
  4. data/lib/rango.rb +47 -78
  5. data/lib/rango/core_ext.rb +21 -0
  6. data/lib/rango/gv/router.rb +42 -0
  7. data/lib/rango/gv/scaffolding.rb +53 -0
  8. data/lib/rango/gv/static.rb +4 -5
  9. data/lib/rango/interactive.rb +18 -0
  10. data/lib/rango/logger.rb +14 -0
  11. data/lib/rango/mini.rb +0 -6
  12. data/lib/rango/mini_render.rb +16 -0
  13. data/lib/rango/mixins/logger.rb +19 -0
  14. data/lib/rango/mixins/message.rb +3 -3
  15. data/lib/rango/mixins/render.rb +5 -5
  16. data/lib/rango/mixins/rendering.rb +13 -13
  17. data/lib/rango/orm/README.textile +24 -0
  18. data/lib/rango/orm/tasks/datamapper.rake +40 -14
  19. data/lib/rango/orm/tasks/sequel.rake +21 -1
  20. data/lib/rango/path.rb +13 -0
  21. data/lib/rango/rack/request.rb +8 -4
  22. data/lib/rango/templates/helpers.rb +84 -86
  23. data/lib/rango/templates/template.rb +50 -53
  24. data/lib/rango/version.rb +1 -1
  25. data/spec/rango/controller_spec.rb +1 -0
  26. data/spec/rango/mixins/message_spec.rb +4 -4
  27. data/spec/rango/mixins/render_spec.rb +4 -4
  28. data/spec/rango/project_spec.rb +2 -0
  29. data/spec/rango/templates/template_spec.rb +18 -18
  30. data/stubs/{project → stack}/content/Gemfile.rbt +0 -0
  31. data/stubs/{project → stack}/content/Rakefile.rbt +0 -0
  32. data/stubs/{project → stack}/content/TODO.txt +0 -0
  33. data/stubs/{project → stack}/content/config.ru.rbt +0 -0
  34. data/stubs/{project → stack}/content/init.rb.rbt +4 -7
  35. data/stubs/{app → stack}/content/models.rb.rbt +0 -0
  36. data/stubs/stack/content/settings_local.rb.rbt +20 -0
  37. data/stubs/{project → stack}/content/spec/%name%/init_spec.rb.rbt +0 -0
  38. data/stubs/{project → stack}/content/spec/%name%/models_spec.rb.rbt +0 -0
  39. data/stubs/{project → stack}/content/spec/%name%/views_spec.rb.rbt +0 -0
  40. data/stubs/{project → stack}/content/spec/spec.opts +0 -0
  41. data/stubs/{project → stack}/content/spec/spec_helper.rb +0 -0
  42. data/stubs/{project → stack}/content/templates/base.html.haml.rbt +0 -0
  43. data/stubs/stack/content/templates/errors/404.html.haml +1 -0
  44. data/stubs/stack/content/templates/errors/500.html.haml +1 -0
  45. data/stubs/{project → stack}/content/templates/index.html.haml +0 -0
  46. data/stubs/{app → stack}/content/views.rb.rbt +13 -0
  47. data/stubs/{app → stack}/metadata.yml +0 -0
  48. data/stubs/{project → stack}/postprocess.rb +0 -0
  49. data/stubs/{project → stack}/setup.rb +0 -0
  50. metadata +82 -43
  51. data/lib/rango/orm/adapter.rb +0 -46
  52. data/lib/rango/orm/adapters/datamapper.rb +0 -26
  53. data/lib/rango/orm/adapters/sequel.rb +0 -18
  54. data/lib/rango/orm/orm.txt +0 -11
  55. data/lib/rango/orm/support/datamapper/support.rb +0 -17
  56. data/stubs/app/content/init.rb.rbt +0 -10
  57. data/stubs/app/setup.rb +0 -13
  58. data/stubs/bigapp/content/init.rb +0 -0
  59. data/stubs/bigapp/content/models/%model%.rb.rbt +0 -6
  60. data/stubs/bigapp/content/views/%controller%.rb.rbt +0 -10
  61. data/stubs/bigapp/content/views/application.rb +0 -0
  62. data/stubs/bigapp/metadata.yml +0 -3
  63. data/stubs/bigapp/setup.rb +0 -12
  64. data/stubs/project/content/settings.rb +0 -13
  65. data/stubs/project/content/settings_local.rb.rbt +0 -6
  66. data/stubs/project/metadata.yml +0 -3
@@ -8,11 +8,11 @@ module Rango
8
8
  extend self # so you can use Rango::RenderMixin.render
9
9
 
10
10
  # @since 0.0.2
11
- def render(path, context = Object.new, locals = Hash.new)
12
- context, locals = Object.new, context if locals.empty? && context.is_a?(Hash)
13
- Rango.logger.inspect(locals: locals)
14
- template = Rango::Templates::Template.new(path, context)
15
- return template.render(locals)
11
+ def render(path, scope = Object.new, context = Hash.new)
12
+ scope, context = Object.new, scope if context.empty? && scope.is_a?(Hash)
13
+ Rango.logger.inspect(context: context)
14
+ template = Rango::Template.new(path, scope)
15
+ return template.render(context)
16
16
  end
17
17
  end
18
18
  end
@@ -5,12 +5,12 @@ require "rango/mixins/render"
5
5
  module Rango
6
6
  module ExplicitRendering
7
7
  include Rango::RenderMixin
8
- def render(template, locals = Hash.new)
9
- super(template, self.context, self.locals.merge!(locals))
8
+ def render(template, context = Hash.new)
9
+ super(template, self.scope, self.context.merge!(context))
10
10
  end
11
11
 
12
12
  # class Posts < Rango::Controller
13
- # def context
13
+ # def scope
14
14
  # Object.new
15
15
  # end
16
16
  #
@@ -22,29 +22,29 @@ module Rango
22
22
  # end
23
23
  #
24
24
  # Context for rendering templates
25
- # This context will be extended by same crucial methods from template mixin
26
- # We are in context of current controller by default
27
- def context
25
+ # This scope will be extended by same crucial methods from template mixin
26
+ # We are in scope of current controller by default
27
+ def scope
28
28
  Object.new.extend(Rango::Helpers)
29
29
  end
30
30
 
31
31
  # def show
32
- # locals[:post] = Post.get(params[:id])
33
- # render "show.html", locals
32
+ # context[:post] = Post.get(params[:id])
33
+ # render "show.html", context
34
34
  # end
35
- def locals
36
- @locals ||= {request: self.request}
35
+ def context
36
+ @context ||= {request: self.request}
37
37
  end
38
38
  end
39
39
 
40
40
  module ImplicitRendering
41
41
  include Rango::RenderMixin
42
- def context
42
+ def scope
43
43
  self
44
44
  end
45
45
 
46
- def render(template) # so you can't specify locals
47
- super template, self.context
46
+ def render(template) # so you can't specify context
47
+ super template, self.scope
48
48
  end
49
49
  end
50
50
  end
@@ -0,0 +1,24 @@
1
+ h1. Kinds of Support
2
+
3
+ h2. Core Support
4
+
5
+ - Tasks for migrations, creating db etc
6
+
7
+ h2. Extended Support
8
+
9
+ - Custom fields (SlugField, ImageField etc)
10
+ - Whatever else
11
+
12
+ h1. Why not ...
13
+
14
+ h2. Save Used ORM in Project.orm or somewhere?
15
+
16
+ Because if you need have aditional support for each ORM, it's part of setup to put @load "myplugin/tasks.rake"@ to user's Rakefile etc, so there is no need for this.
17
+
18
+ h2. Support @config/database.yml@
19
+
20
+ Because it has no point. You can use API of your ORM directly.
21
+
22
+ h2. Define @form_for@
23
+
24
+ It's job of your helpers.
@@ -3,9 +3,8 @@
3
3
  namespace :db do
4
4
  # @since 0.0.2
5
5
  desc "Automigrate the database. It will destroy all the data!"
6
- task :automigrate, :environment do |task, args|
6
+ task :automigrate, :environment, :needs => :environment do |task, args|
7
7
  RANGO_ENV = args.environment || ENV["RANGO_ENV"] || "development"
8
- Rake::Task[:environment].invoke
9
8
  Rango.logger.info("[#{Rango.environment}] Migrating databases ...")
10
9
  result = DataMapper.auto_migrate!
11
10
  Rango.logger.debug("Result: #{result.inspect}")
@@ -13,29 +12,56 @@ namespace :db do
13
12
 
14
13
  # @since 0.0.2
15
14
  desc "Autoupgrade the database structure. Data should stay untouched."
16
- task :autupgrade, :environment do |task, args|
15
+ task :autupgrade, :environment, :needs => :environment do |task, args|
17
16
  RANGO_ENV = args.environment || ENV["RANGO_ENV"] || "development"
18
- Rake::Task[:environment].invoke
19
17
  Rango.logger.info("[#{Rango.environment}] Upgrading databases ...")
20
18
  result = DataMapper.auto_upgrade!
21
19
  Rango.logger.debug("Result: #{result.inspect}")
22
20
  end
23
21
 
22
+ desc "Report count of objects in database"
23
+ task :report, :environment, :needs => :environment do |task, args|
24
+ RANGO_ENV = args.environment || ENV["RANGO_ENV"] || "development"
25
+ ObjectSpace.classes.each do |klass|
26
+ if klass.included(DataMapper::Resource)
27
+ puts "#{model_class}: #{model_class.count}"
28
+ end
29
+ end
30
+ end
31
+
24
32
  # @since 0.0.2
25
33
  desc "Run migrations"
26
- task :migrate, :environment do |task, args|
34
+ task :migrate, :environment, :needs => :environment do |task, args|
27
35
  RANGO_ENV = args.environment || ENV["RANGO_ENV"] || "development"
28
- Rake::Task[:environment].invoke
29
- abort "This task isn't implemented so far! You might want to use db:automigrate or db:autoupgrade instead."
36
+ abort "Use rake db:migrate:up[version] or db:migrate:down[version]"
30
37
  end
31
38
 
32
- desc "Report count of objects in database"
33
- task :report, :environment do |task, args|
34
- RANGO_ENV = args.environment || ENV["RANGO_ENV"] || "development"
35
- Rake::Task[:environment].invoke
36
- require "rango/orm/adapters/datamapper" # should be loaded in runtime, but isn't at the moment
37
- Rango::ORM::Datamapper.models.each do |model_class|
38
- puts "#{model_class}: #{model_class.count}"
39
+ namespace :migrate do
40
+ task :load => :environment do
41
+ begin
42
+ require "dm-migrations/migration_runner"
43
+ rescue LoadError
44
+ abort "You have to install dm-migrations gem for this!"
45
+ end
46
+ FileList["db/migrations/*.rb"].each do |migration|
47
+ load migration
48
+ end
49
+ end
50
+
51
+ # rake db:migrate:up[version]
52
+ # rake db:migrate:up[,environment]
53
+ desc "Migrate up using migrations"
54
+ task :up, :version, :environment, :needs => :load do |task, args|
55
+ version = args.version || ENV['VERSION']
56
+ raise ArgumentError, "You have to specify version!" if version.nil?
57
+ migrate_up!(version)
58
+ end
59
+
60
+ desc "Migrate down using migrations"
61
+ task :down, :version, :environment, :needs => :load do |task, args|
62
+ version = args.version || ENV['VERSION']
63
+ raise ArgumentError, "You have to specify version!" if version.nil?
64
+ migrate_down!(version)
39
65
  end
40
66
  end
41
67
  end
@@ -1,3 +1,23 @@
1
1
  # encoding: utf-8
2
2
 
3
- raise "Sequel isn't supported so far!"
3
+ namespace :db do
4
+ desc "Perform migration using migrations in schema/migrations"
5
+ task :migrate, :version, :environment, :needs => :environment do |task, args|
6
+ require "sequel/extensions/migration"
7
+ version = args.version || (ENV["VERSION"].to_i unless ENV["VERSION"].nil?) || nil
8
+ Sequel::Migrator.apply(Sequel::Model.db, "db/migrations", version)
9
+ end
10
+
11
+ desc "Drop all tables"
12
+ task :drop_tables => :sequel_env do
13
+ Sequel::Model.db.drop_table *Sequel::Model.db.tables
14
+ end
15
+
16
+ desc "Drop all tables and perform migrations"
17
+ task :reset => [:sequel_env, :drop_tables, :migrate]
18
+
19
+ desc "Truncate all tables in database"
20
+ task :truncate => :sequel_env do
21
+ Sequel::Model.db << "TRUNCATE #{db.tables.join(', ')} CASCADE;"
22
+ end
23
+ end
data/lib/rango/path.rb ADDED
@@ -0,0 +1,13 @@
1
+ # encoding: utf-8
2
+
3
+ require "rango"
4
+ require_gem "media-path"
5
+
6
+ # @since 0.0.2
7
+ # @example
8
+ # Rango.path
9
+ # # => /usr/lib/ruby/lib/ruby/site_ruby/1.8/rango
10
+ # @return [Path] Rango root path
11
+ def Rango.path
12
+ @path ||= MediaPath.new(self.root)
13
+ end
@@ -153,10 +153,14 @@ module Rango
153
153
  # @since 0.0.1
154
154
  # @example: "blog" or "user.blog"
155
155
  # @return [String] Subdomain name.
156
- def subdomain
157
- parts = host.split(".")
158
- index = parts.index(self.domain)
159
- parts[0..(index - 1)]
156
+ def subdomains(tld_length = 1) # we set tld_length to 1, use 2 for co.uk or similar
157
+ # cache the result so we only compute it once.
158
+ @env['rack.env.subdomains'] ||= begin
159
+ # check if the current host is an IP address, if so return an empty array
160
+ return [] if (host.nil? ||
161
+ /\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.match(host))
162
+ host.split('.')[0...(1 - tld_length - 2)] # pull everything except the TLD
163
+ end
160
164
  end
161
165
 
162
166
  def base_url
@@ -3,105 +3,103 @@
3
3
  require "rango"
4
4
 
5
5
  module Rango
6
- module Templates
7
- module TemplateHelpers
8
- def self.extended(scope)
9
- class << scope
10
- attr_accessor :_template
11
- # @example Capture being used in a .html.erb page:
12
- # <% @foo = capture do %>
13
- # <p>Some Foo content!</p>
14
- # <% end %>
15
- #
16
- # @params [*args] Arguments to pass to the block.
17
- # @params [&block] The template block to call.
18
- # @return [String] The output of the block.
19
- # @api private
20
- def capture(*args, &block)
21
- capture_method = "capture_#{self._template.adapter}"
22
- if self.respond_to?(capture_method) # tilt doesn't support @_out_buf for haml
23
- self.send("capture_#{self._template.adapter}", *args, &block)
24
- else
25
- # @_out_buf comes from tilt
26
- unless self.instance_variable_defined?("@_out_buf")
27
- raise "Adapter #{self._template.adapter} doesn't support capturing"
28
- end
29
- _old_buf, @_out_buf = @_out_buf, ""
30
- block.call(*args)
31
- @_out_buf = _old_buf.chomp.strip
6
+ module TemplateHelpers
7
+ def self.extended(scope)
8
+ class << scope
9
+ attr_accessor :_template
10
+ # @example Capture being used in a .html.erb page:
11
+ # <% @foo = capture do %>
12
+ # <p>Some Foo content!</p>
13
+ # <% end %>
14
+ #
15
+ # @params [*args] Arguments to pass to the block.
16
+ # @params [&block] The template block to call.
17
+ # @return [String] The output of the block.
18
+ # @api private
19
+ def capture(*args, &block)
20
+ capture_method = "capture_#{self._template.adapter}"
21
+ if self.respond_to?(capture_method) # tilt doesn't support @_out_buf for haml
22
+ self.send("capture_#{self._template.adapter}", *args, &block)
23
+ else
24
+ # @_out_buf comes from tilt
25
+ unless self.instance_variable_defined?("@_out_buf")
26
+ raise "Adapter #{self._template.adapter} doesn't support capturing"
32
27
  end
28
+ _old_buf, @_out_buf = @_out_buf, ""
29
+ block.call(*args)
30
+ @_out_buf = _old_buf.chomp.strip
33
31
  end
32
+ end
34
33
 
35
- def concat(string)
36
- concat_method = "concat_#{self._template.adapter}"
37
- if self.respond_to?(concat_method) # tilt doesn't support @_out_buf for haml
38
- self.send("concat_#{self._template.adapter}", string)
39
- else
40
- # @_out_buf comes from tilt
41
- unless self.instance_variable_defined?("@_out_buf")
42
- raise "Adapter #{self._template.adapter} doesn't support concating"
43
- end
44
- @_out_buf << string
34
+ def concat(string)
35
+ concat_method = "concat_#{self._template.adapter}"
36
+ if self.respond_to?(concat_method) # tilt doesn't support @_out_buf for haml
37
+ self.send("concat_#{self._template.adapter}", string)
38
+ else
39
+ # @_out_buf comes from tilt
40
+ unless self.instance_variable_defined?("@_out_buf")
41
+ raise "Adapter #{self._template.adapter} doesn't support concating"
45
42
  end
43
+ @_out_buf << string
46
44
  end
47
45
  end
48
46
  end
47
+ end
49
48
 
50
- def self.included(scope_class)
51
- scope_class.class_eval { attr_accessor :_template}
52
- end
49
+ def self.included(scope_class)
50
+ scope_class.class_eval { attr_accessor :_template}
51
+ end
53
52
 
54
- # post/show.html: it's block is the block we like to see in output
55
- # post/base.html
56
- # base.html: here it will be rendered, so we need block to returns the correct block code
57
- # @since 0.0.2
58
- def block(name, value = nil, &block)
59
- value = self._template.scope.capture(&block) if value.nil? && block
60
- self._template.blocks[name] ||= value
61
- return self._template.blocks[name]
62
- end
53
+ # post/show.html: it's block is the block we like to see in output
54
+ # post/base.html
55
+ # base.html: here it will be rendered, so we need block to returns the correct block code
56
+ # @since 0.0.2
57
+ def block(name, value = nil, &block)
58
+ value = self._template.scope.capture(&block) if value.nil? && block
59
+ self._template.blocks[name] ||= value
60
+ return self._template.blocks[name]
61
+ end
63
62
 
64
- # - extend_block(:head) do
65
- # != pupu :lighter, syntax: "html", theme: "standard"
66
- # != block(:head)
67
- #
68
- # TODO: something more intuitive like:
69
- # - block(:head) do
70
- # != pupu :lighter, syntax: "html", theme: "standard"
71
- # != block(:head)
72
- #
73
- # OR even:
74
- # - block(:head) do
75
- # != pupu :lighter, syntax: "html", theme: "standard"
76
- # = superblock
77
- def extend_block(name, value = nil, &block)
78
- value = self._template.scope.capture(&block) if value.nil? && block
79
- self._template.blocks[name] += value
80
- return self._template.blocks[name]
81
- end
63
+ # - extend_block(:head) do
64
+ # != pupu :lighter, syntax: "html", theme: "standard"
65
+ # != block(:head)
66
+ #
67
+ # TODO: something more intuitive like:
68
+ # - block(:head) do
69
+ # != pupu :lighter, syntax: "html", theme: "standard"
70
+ # != block(:head)
71
+ #
72
+ # OR even:
73
+ # - block(:head) do
74
+ # != pupu :lighter, syntax: "html", theme: "standard"
75
+ # = superblock
76
+ def extend_block(name, value = nil, &block)
77
+ value = self._template.scope.capture(&block) if value.nil? && block
78
+ self._template.blocks[name] += value
79
+ return self._template.blocks[name]
80
+ end
82
81
 
83
- # partial "products/list"
84
- # @since 0.0.2
85
- def partial(template, locals = Hash.new)
86
- if template.match(%r[/])
87
- path, last = File.split(template)[0..-1]
88
- template = File.join(path, "_#{last}")
89
- else
90
- template = "_#{template}"
91
- end
92
- template = Rango::Templates::Template.new(template, self._template.scope, locals)
93
- template.partial = true
94
- # TODO: #block in partial templates
95
- output = template.render
96
- return output
82
+ # partial "products/list"
83
+ # @since 0.0.2
84
+ def partial(template, context = Hash.new)
85
+ if template.match(%r[/])
86
+ path, last = File.split(template)[0..-1]
87
+ template = File.join(path, "_#{last}")
88
+ else
89
+ template = "_#{template}"
97
90
  end
91
+ template = Rango::Template.new(template, self._template.scope, context)
92
+ template.partial = true
93
+ # TODO: #block in partial templates
94
+ output = template.render
95
+ return output
96
+ end
98
97
 
99
- # extends "base.html"
100
- # @since 0.0.2
101
- def extends(path)
102
- # we can't just create a new template, because it has to do it after it reads the whole file
103
- self._template.supertemplate = path
104
- end
98
+ # extends "base.html"
99
+ # @since 0.0.2
100
+ def extends(path)
101
+ # we can't just create a new template, because it has to do it after it reads the whole file
102
+ self._template.supertemplate = path
105
103
  end
106
104
  end
107
105
  end
@@ -3,6 +3,7 @@
3
3
  require "rango/templates/exts/tilt"
4
4
  require "rubyexts/attribute"
5
5
  require "rubyexts/string" # String#snake_case
6
+ require "rubyexts/class" # cattr_accessor
6
7
  require "rango/templates/helpers"
7
8
  require "rango/exceptions"
8
9
 
@@ -11,70 +12,66 @@ module Rango
11
12
  TemplateNotFound = Class.new(NotFound)
12
13
  end
13
14
 
14
- module Templates
15
- class Template
16
- # template -> supertemplate is the same relationship as class -> superclass
17
- # @since 0.0.2
18
- attr_accessor :path, :scope, :supertemplate
15
+ class Template
16
+ cattr_accessor :template_paths
19
17
 
20
- # @since 0.0.2
21
- attribute :blocks, Hash.new
18
+ # template -> supertemplate is the same relationship as class -> superclass
19
+ # @since 0.0.2
20
+ attr_accessor :path, :scope, :supertemplate
22
21
 
23
- # @since 0.0.2
24
- def initialize(path, scope = Object.new)
25
- self.path = path#[scope.class.template_prefix.chomp("/"), template].join("/")
26
- self.scope = scope.extend(TemplateHelpers)
27
- self.scope._template = self
28
- end
22
+ # @since 0.0.2
23
+ attribute :blocks, Hash.new
29
24
 
30
- # @since 0.0.2
31
- def fullpath
32
- @fullpath ||= begin
33
- if self.path.match(/^(\/|\.)/) # /foo or ./foo
34
- Dir[self.path, "#{self.path}.*"].first
35
- else
36
- self.find_in_template_dirs
37
- end
38
- end
39
- end
25
+ # @since 0.0.2
26
+ def initialize(path, scope = Object.new)
27
+ self.path = path#[scope.class.template_prefix.chomp("/"), template].join("/")
28
+ self.scope = scope.extend(TemplateHelpers)
29
+ self.scope._template = self
30
+ end
40
31
 
41
- def adapter
42
- self.template.class.name.split("::").last.snake_case.sub("_template", "")
32
+ # @since 0.0.2
33
+ def fullpath
34
+ @fullpath ||= begin
35
+ if self.path.match(/^(\/|\.)/) # /foo or ./foo
36
+ Dir[self.path, "#{self.path}.*"].first
37
+ else
38
+ self.find_in_template_paths
39
+ end
43
40
  end
41
+ end
44
42
 
45
- def extension # haml, erb ...
46
- File.extname(path)[1..-1]
47
- end
43
+ def adapter
44
+ self.template.class.name.split("::").last.snake_case.sub("_template", "")
45
+ end
48
46
 
49
- def options
50
- @options ||= Project.settings.send(self.extension) rescue Hash.new
51
- end
47
+ def extension # haml, erb ...
48
+ File.extname(path)[1..-1]
49
+ end
52
50
 
53
- def template
54
- @template ||= Tilt.new(self.fullpath, nil, self.options)
55
- end
51
+ def template(options = Hash.new)
52
+ @template ||= Tilt.new(self.fullpath, nil, options)
53
+ end
56
54
 
57
- # @since 0.0.2
58
- def render(locals = Hash.new)
59
- raise Errors::TemplateNotFound.new("Template #{self.path} wasn't found in these template_dirs: #{Project.settings.template_dirs.inspect}") if self.fullpath.nil?
60
- value = self.template.render(self.scope, locals)
61
- Rango.logger.info("Rendering template #{self.path}")
62
- Rango.logger.inspect(self.blocks)
63
- if self.supertemplate
64
- Rango.logger.debug("Extends call: #{self.supertemplate}")
65
- supertemplate = self.class.new(self.supertemplate, self.scope)
66
- supertemplate.blocks = self.blocks
67
- return supertemplate.render(locals)
68
- end
69
- value
55
+ # @since 0.0.2
56
+ def render(context = Hash.new)
57
+ raise Errors::TemplateNotFound.new("Template #{self.path} wasn't found in these template_paths: #{self.template_paths.inspect}") if self.fullpath.nil?
58
+ value = self.template.render(self.scope, context)
59
+ Rango.logger.info("Rendering template #{self.path}")
60
+ # Rango.logger.inspect(self.blocks)
61
+ if self.supertemplate
62
+ Rango.logger.debug("Extends call: #{self.supertemplate}")
63
+ supertemplate = self.class.new(self.supertemplate, self.scope)
64
+ supertemplate.blocks = self.blocks
65
+ return supertemplate.render(context)
70
66
  end
67
+ value
68
+ end
71
69
 
72
- protected
73
- def find_in_template_dirs
74
- Project.settings.template_dirs.each do |directory|
75
- path = File.join(directory, self.path)
76
- return Dir[path, "#{path}.*"].first
77
- end
70
+ protected
71
+ def find_in_template_paths
72
+ self.template_paths.each do |directory|
73
+ path = File.join(directory, self.path)
74
+ return Dir[path, "#{path}.*"].first
78
75
  end
79
76
  end
80
77
  end