styler 0.1.2 → 0.2.0

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.
@@ -7,21 +7,8 @@ module Styler
7
7
  end
8
8
  end
9
9
 
10
- module Styler
11
- module RangoMixin
12
- include Rango::ImplicitRendering
13
- def render(template, *models)
14
- models.each {|name|
15
- instance_variable_set(
16
- "@#{name}",
17
- ::Styler.new_style_for(
18
- instance_variable_get("@#{name}"),
19
- {__controller: self}
20
- )
21
- )
22
- }
23
- super(template)
24
- end
10
+ module Rango::Helpers
11
+ def style(model)
12
+ Styler.new_style_for(model)
25
13
  end
26
14
  end
27
-
@@ -42,14 +42,14 @@ module Styler
42
42
  def initialize(model, context={})
43
43
  serialize_from_hash(context)
44
44
  @model = model
45
- @type ||= :default
45
+ @__type ||= :default
46
46
  end
47
47
 
48
48
  attr_reader :model, :request
49
49
 
50
50
  # Use like style.as(:widget)
51
51
  def as(type)
52
- @type = type
52
+ @__type = type
53
53
  self
54
54
  end
55
55
 
@@ -68,7 +68,7 @@ module Styler
68
68
 
69
69
  # This method compiles the default template path.
70
70
  def compile_template_path
71
- "#{__class__.to_s.downcase.gsub('::','/')}/#{@type}"
71
+ "#{__class__.to_s.downcase.gsub('::','/')}/#{@__type}"
72
72
  end
73
73
 
74
74
  alias_method :__class__, :class
@@ -33,20 +33,20 @@ BareTest.suite do
33
33
  setup :style, "a style" do
34
34
  @model = Model::Foo.new
35
35
  @style = ::Styler.new_style_for(@model)
36
- @result = [["style/foo/default"], {:@model => @model, :@type => :default}]
36
+ @result = [["style/foo/default"], {:@model => @model, :@__type => :default}]
37
37
  end
38
38
  setup :style, "a complex style" do
39
39
  @model = Model::Foo.new
40
40
  @style = ::Styler.new_style_for(@model)
41
41
  @style.with(:bla => "foo")
42
- @result = [["style/foo/default"], {:@model => @model, :@type => :default, :@bla => "foo"}]
42
+ @result = [["style/foo/default"], {:@model => @model, :@__type => :default, :@bla => "foo"}]
43
43
  end
44
44
  setup :style, "a style with context" do
45
45
  model = Model::Foo.new
46
46
  style = ::Styler.new_style_for(model)
47
47
  style.with(:bla => "foo")
48
48
  @style = style.foo
49
- @result = [["style/bar/default"], {:@foo => style, :@model => @style.model, :@type => :default, :@bla => "foo"}]
49
+ @result = [["style/bar/default"], {:@foo => style, :@model => @style.model, :@__type => :default, :@bla => "foo"}]
50
50
  end
51
51
  assert "it renders :style correctly" do
52
52
  equal(@result, @style.to_s)
metadata CHANGED
@@ -4,16 +4,16 @@ version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
6
  - 0
7
- - 1
8
7
  - 2
9
- version: 0.1.2
8
+ - 0
9
+ version: 0.2.0
10
10
  platform: ruby
11
11
  authors:
12
12
  - Simon Hafner aka Tass
13
13
  autorequire:
14
14
  bindir: bin
15
15
  cert_chain:
16
- date: 2010-03-15 00:00:00 +01:00
16
+ date: 2010-03-18 00:00:00 +01:00
17
17
  default_executable:
18
18
  dependencies: []
19
19