rango 0.1.1.2.5 → 0.1.1.2.6
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/lib/rango/mixins/rendering.rb +3 -0
- data/lib/rango/router/adapters/usher.rb +2 -1
- data/lib/rango/templates/helpers.rb +7 -7
- data/lib/rango/templates/template.rb +8 -8
- data/lib/rango/version.rb +1 -1
- data/stubs/app/content/views.rb.rbt +2 -2
- data/stubs/project/content/init.rb.rbt +3 -0
- data/stubs/project/content/spec/spec_helper.rb +1 -0
- metadata +1 -1
@@ -10,7 +10,8 @@ module Rango
|
|
10
10
|
module UrlHelper
|
11
11
|
# url(:login)
|
12
12
|
def url(*args)
|
13
|
-
Project.router.router.
|
13
|
+
raise "You have to asign your routes to Project.router, for example Project.router = Usher::Interface.for(:rack) { get('/') }" if Project.router.nil?
|
14
|
+
self.router.router.generator.generate(*args)
|
14
15
|
end
|
15
16
|
end
|
16
17
|
end
|
@@ -5,8 +5,8 @@ require "rango"
|
|
5
5
|
module Rango
|
6
6
|
module Templates
|
7
7
|
module TemplateHelpers
|
8
|
-
def self.extended(
|
9
|
-
class <<
|
8
|
+
def self.extended(scope)
|
9
|
+
class << scope
|
10
10
|
attr_accessor :_template
|
11
11
|
# @example Capture being used in a .html.erb page:
|
12
12
|
# <% @foo = capture do %>
|
@@ -47,8 +47,8 @@ module Rango
|
|
47
47
|
end
|
48
48
|
end
|
49
49
|
|
50
|
-
def self.included(
|
51
|
-
|
50
|
+
def self.included(scope_class)
|
51
|
+
scope_class.class_eval { attr_accessor :_template}
|
52
52
|
end
|
53
53
|
|
54
54
|
# post/show.html: it's block is the block we like to see in output
|
@@ -56,7 +56,7 @@ module Rango
|
|
56
56
|
# base.html: here it will be rendered, so we need block to returns the correct block code
|
57
57
|
# @since 0.0.2
|
58
58
|
def block(name, value = nil, &block)
|
59
|
-
value = self._template.
|
59
|
+
value = self._template.scope.capture(&block) if value.nil? && block
|
60
60
|
self._template.blocks[name] ||= value
|
61
61
|
return self._template.blocks[name]
|
62
62
|
end
|
@@ -75,7 +75,7 @@ module Rango
|
|
75
75
|
# != pupu :lighter, syntax: "html", theme: "standard"
|
76
76
|
# = superblock
|
77
77
|
def extend_block(name, value = nil, &block)
|
78
|
-
value = self._template.
|
78
|
+
value = self._template.scope.capture(&block) if value.nil? && block
|
79
79
|
self._template.blocks[name] += value
|
80
80
|
return self._template.blocks[name]
|
81
81
|
end
|
@@ -89,7 +89,7 @@ module Rango
|
|
89
89
|
else
|
90
90
|
template = "_#{template}"
|
91
91
|
end
|
92
|
-
template = Rango::Templates::Template.new(template, self._template.
|
92
|
+
template = Rango::Templates::Template.new(template, self._template.scope, locals)
|
93
93
|
template.partial = true
|
94
94
|
# TODO: #block in partial templates
|
95
95
|
output = template.render
|
@@ -15,16 +15,16 @@ module Rango
|
|
15
15
|
class Template
|
16
16
|
# template -> supertemplate is the same relationship as class -> superclass
|
17
17
|
# @since 0.0.2
|
18
|
-
attr_accessor :path, :
|
18
|
+
attr_accessor :path, :scope, :supertemplate
|
19
19
|
|
20
20
|
# @since 0.0.2
|
21
21
|
attribute :blocks, Hash.new
|
22
22
|
|
23
23
|
# @since 0.0.2
|
24
|
-
def initialize(path,
|
25
|
-
self.path = path#[
|
26
|
-
self.
|
27
|
-
self.
|
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
28
|
end
|
29
29
|
|
30
30
|
# @since 0.0.2
|
@@ -57,14 +57,14 @@ module Rango
|
|
57
57
|
# @since 0.0.2
|
58
58
|
def render(locals = Hash.new)
|
59
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.
|
60
|
+
value = self.template.render(self.scope, locals)
|
61
61
|
Rango.logger.info("Rendering template #{self.path}")
|
62
62
|
Rango.logger.inspect(self.blocks)
|
63
63
|
if self.supertemplate
|
64
64
|
Rango.logger.debug("Extends call: #{self.supertemplate}")
|
65
|
-
supertemplate = self.class.new(self.supertemplate, self.
|
65
|
+
supertemplate = self.class.new(self.supertemplate, self.scope)
|
66
66
|
supertemplate.blocks = self.blocks
|
67
|
-
return supertemplate.render(
|
67
|
+
return supertemplate.render(locals)
|
68
68
|
end
|
69
69
|
value
|
70
70
|
end
|
data/lib/rango/version.rb
CHANGED
@@ -3,15 +3,15 @@
|
|
3
3
|
# http://wiki.github.com/botanicus/rango/controllers
|
4
4
|
|
5
5
|
require "rango/controller"
|
6
|
-
require "rango/mixins/render"
|
7
6
|
require "rango/mixins/filters"
|
7
|
+
require "rango/mixins/rendering"
|
8
8
|
require "rango/mixins/message"
|
9
9
|
|
10
10
|
module <%= @name.camel_case %>
|
11
11
|
class Application < Rango::Controller
|
12
12
|
include Rango::FiltersMixin
|
13
13
|
include Rango::MessageMixin
|
14
|
-
include Rango::
|
14
|
+
include Rango::ExplicitRendering
|
15
15
|
end
|
16
16
|
|
17
17
|
class ShowCase < Application
|
@@ -39,7 +39,10 @@ Rango.boot(environment: environment)
|
|
39
39
|
require_relative "<%= @name %>/init.rb"
|
40
40
|
|
41
41
|
# database connection
|
42
|
+
<% case @orm %>
|
43
|
+
<% when "datamapper" %>
|
42
44
|
DataMapper.setup(:default, "sqlite3:#{Rango.environment}.db")
|
45
|
+
<% end %>
|
43
46
|
|
44
47
|
# if you will run this script with -i argument, interactive session will begin
|
45
48
|
Rango.interactive if ARGV.delete("-i")
|