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.
@@ -1,7 +1,10 @@
1
1
  # encoding: utf-8
2
2
 
3
+ require "rango/mixins/render"
4
+
3
5
  module Rango
4
6
  module ExplicitRendering
7
+ include Rango::RenderMixin
5
8
  def render(template, locals = Hash.new)
6
9
  super(template, self.locals.merge!(locals))
7
10
  end
@@ -10,7 +10,8 @@ module Rango
10
10
  module UrlHelper
11
11
  # url(:login)
12
12
  def url(*args)
13
- Project.router.router.generator.generate(*args)
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(context)
9
- class << context
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(context_class)
51
- context_class.class_eval { attr_accessor :_template}
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.context.capture(&block) if value.nil? && block
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.context.capture(&block) if value.nil? && block
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.context, locals)
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, :context, :supertemplate
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, context = Object.new)
25
- self.path = path#[context.class.template_prefix.chomp("/"), template].join("/")
26
- self.context = context.extend(TemplateHelpers)
27
- self.context._template = 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.context, locals)
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.context)
65
+ supertemplate = self.class.new(self.supertemplate, self.scope)
66
66
  supertemplate.blocks = self.blocks
67
- return supertemplate.render(self.scope, locals)
67
+ return supertemplate.render(locals)
68
68
  end
69
69
  value
70
70
  end
data/lib/rango/version.rb CHANGED
@@ -3,5 +3,5 @@
3
3
  # NOTE: Do not edit this file manually, this
4
4
  # file is regenerated by task rake version:increase
5
5
  module Rango
6
- VERSION ||= "0.1.1.2.5"
6
+ VERSION ||= "0.1.1.2.6"
7
7
  end
@@ -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::RenderMixin
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")
@@ -8,6 +8,7 @@ RANGO_ENV = "test"
8
8
  require_relative "../init.rb"
9
9
 
10
10
  # load config.ru
11
+ require "rango/utils"
11
12
  Rango::Utils.load_rackup
12
13
 
13
14
  # webrat
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rango
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1.2.5
4
+ version: 0.1.1.2.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - "Jakub \xC5\xA0\xC5\xA5astn\xC3\xBD aka Botanicus"