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.
- data/CHANGELOG +7 -0
- data/README.textile +2 -0
- data/bin/rango +5 -2
- data/lib/rango.rb +47 -78
- data/lib/rango/core_ext.rb +21 -0
- data/lib/rango/gv/router.rb +42 -0
- data/lib/rango/gv/scaffolding.rb +53 -0
- data/lib/rango/gv/static.rb +4 -5
- data/lib/rango/interactive.rb +18 -0
- data/lib/rango/logger.rb +14 -0
- data/lib/rango/mini.rb +0 -6
- data/lib/rango/mini_render.rb +16 -0
- data/lib/rango/mixins/logger.rb +19 -0
- data/lib/rango/mixins/message.rb +3 -3
- data/lib/rango/mixins/render.rb +5 -5
- data/lib/rango/mixins/rendering.rb +13 -13
- data/lib/rango/orm/README.textile +24 -0
- data/lib/rango/orm/tasks/datamapper.rake +40 -14
- data/lib/rango/orm/tasks/sequel.rake +21 -1
- data/lib/rango/path.rb +13 -0
- data/lib/rango/rack/request.rb +8 -4
- data/lib/rango/templates/helpers.rb +84 -86
- data/lib/rango/templates/template.rb +50 -53
- data/lib/rango/version.rb +1 -1
- data/spec/rango/controller_spec.rb +1 -0
- data/spec/rango/mixins/message_spec.rb +4 -4
- data/spec/rango/mixins/render_spec.rb +4 -4
- data/spec/rango/project_spec.rb +2 -0
- data/spec/rango/templates/template_spec.rb +18 -18
- data/stubs/{project → stack}/content/Gemfile.rbt +0 -0
- data/stubs/{project → stack}/content/Rakefile.rbt +0 -0
- data/stubs/{project → stack}/content/TODO.txt +0 -0
- data/stubs/{project → stack}/content/config.ru.rbt +0 -0
- data/stubs/{project → stack}/content/init.rb.rbt +4 -7
- data/stubs/{app → stack}/content/models.rb.rbt +0 -0
- data/stubs/stack/content/settings_local.rb.rbt +20 -0
- data/stubs/{project → stack}/content/spec/%name%/init_spec.rb.rbt +0 -0
- data/stubs/{project → stack}/content/spec/%name%/models_spec.rb.rbt +0 -0
- data/stubs/{project → stack}/content/spec/%name%/views_spec.rb.rbt +0 -0
- data/stubs/{project → stack}/content/spec/spec.opts +0 -0
- data/stubs/{project → stack}/content/spec/spec_helper.rb +0 -0
- data/stubs/{project → stack}/content/templates/base.html.haml.rbt +0 -0
- data/stubs/stack/content/templates/errors/404.html.haml +1 -0
- data/stubs/stack/content/templates/errors/500.html.haml +1 -0
- data/stubs/{project → stack}/content/templates/index.html.haml +0 -0
- data/stubs/{app → stack}/content/views.rb.rbt +13 -0
- data/stubs/{app → stack}/metadata.yml +0 -0
- data/stubs/{project → stack}/postprocess.rb +0 -0
- data/stubs/{project → stack}/setup.rb +0 -0
- metadata +82 -43
- data/lib/rango/orm/adapter.rb +0 -46
- data/lib/rango/orm/adapters/datamapper.rb +0 -26
- data/lib/rango/orm/adapters/sequel.rb +0 -18
- data/lib/rango/orm/orm.txt +0 -11
- data/lib/rango/orm/support/datamapper/support.rb +0 -17
- data/stubs/app/content/init.rb.rbt +0 -10
- data/stubs/app/setup.rb +0 -13
- data/stubs/bigapp/content/init.rb +0 -0
- data/stubs/bigapp/content/models/%model%.rb.rbt +0 -6
- data/stubs/bigapp/content/views/%controller%.rb.rbt +0 -10
- data/stubs/bigapp/content/views/application.rb +0 -0
- data/stubs/bigapp/metadata.yml +0 -3
- data/stubs/bigapp/setup.rb +0 -12
- data/stubs/project/content/settings.rb +0 -13
- data/stubs/project/content/settings_local.rb.rbt +0 -6
- data/stubs/project/metadata.yml +0 -3
data/lib/rango/mixins/render.rb
CHANGED
@@ -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,
|
12
|
-
|
13
|
-
Rango.logger.inspect(
|
14
|
-
template = Rango::
|
15
|
-
return template.render(
|
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,
|
9
|
-
super(template, self.
|
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
|
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
|
26
|
-
# We are in
|
27
|
-
def
|
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
|
-
#
|
33
|
-
# render "show.html",
|
32
|
+
# context[:post] = Post.get(params[:id])
|
33
|
+
# render "show.html", context
|
34
34
|
# end
|
35
|
-
def
|
36
|
-
@
|
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
|
42
|
+
def scope
|
43
43
|
self
|
44
44
|
end
|
45
45
|
|
46
|
-
def render(template) # so you can't specify
|
47
|
-
super template, self.
|
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
|
-
|
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
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
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
|
-
|
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
|
data/lib/rango/rack/request.rb
CHANGED
@@ -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
|
157
|
-
|
158
|
-
|
159
|
-
|
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
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
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
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
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
|
-
|
51
|
-
|
52
|
-
|
49
|
+
def self.included(scope_class)
|
50
|
+
scope_class.class_eval { attr_accessor :_template}
|
51
|
+
end
|
53
52
|
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
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
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
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
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
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
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
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
|
-
|
15
|
-
|
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
|
-
|
21
|
-
|
18
|
+
# template -> supertemplate is the same relationship as class -> superclass
|
19
|
+
# @since 0.0.2
|
20
|
+
attr_accessor :path, :scope, :supertemplate
|
22
21
|
|
23
|
-
|
24
|
-
|
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
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
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
|
-
|
42
|
-
|
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
|
-
|
46
|
-
|
47
|
-
|
43
|
+
def adapter
|
44
|
+
self.template.class.name.split("::").last.snake_case.sub("_template", "")
|
45
|
+
end
|
48
46
|
|
49
|
-
|
50
|
-
|
51
|
-
|
47
|
+
def extension # haml, erb ...
|
48
|
+
File.extname(path)[1..-1]
|
49
|
+
end
|
52
50
|
|
53
|
-
|
54
|
-
|
55
|
-
|
51
|
+
def template(options = Hash.new)
|
52
|
+
@template ||= Tilt.new(self.fullpath, nil, options)
|
53
|
+
end
|
56
54
|
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
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
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
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
|