ice 0.5.0 → 0.5.1
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/README.markdown +6 -2
- data/lib/ice.rb +12 -3
- data/lib/ice/base_cube.rb +28 -18
- metadata +2 -2
data/README.markdown
CHANGED
@@ -26,7 +26,9 @@ Ice allows you to write your templates in one of two formats.
|
|
26
26
|
<% end %>
|
27
27
|
</table>
|
28
28
|
|
29
|
-
Eco-formatted files may also exist in your views directory, provided they have a .eco extension.
|
29
|
+
Eco-formatted files may also exist in your views directory, provided they have a .eco extension. An example of how this works is in [this blog post](http://ludicast.com/articles/3-ice-templates).
|
30
|
+
|
31
|
+
Also, the templates may be compiled on demand with the method:
|
30
32
|
|
31
33
|
Ice::Handlers::Eco.convert_template(template_text, variables)
|
32
34
|
|
@@ -41,7 +43,9 @@ The CoffeeKup equivalent to the above Eco template is:
|
|
41
43
|
td -> user.name
|
42
44
|
td -> mailTo(user.email)
|
43
45
|
|
44
|
-
Similarly, these CoffeeKup files may exist on your filesystem provided they have a .coffeekup extension.
|
46
|
+
Similarly, these CoffeeKup files may exist on your filesystem provided they have a .coffeekup extension. A demo of this is in [this screencast](http://vimeo.com/25907220/).
|
47
|
+
|
48
|
+
And you'd compile them on demand with:
|
45
49
|
|
46
50
|
Ice::Handlers::CoffeeKup.convert_template(template_text, variables)
|
47
51
|
|
data/lib/ice.rb
CHANGED
@@ -10,9 +10,18 @@ require 'rails'
|
|
10
10
|
require 'ice/handlers/eco/handler'
|
11
11
|
require 'ice/handlers/coffeekup/handler'
|
12
12
|
|
13
|
-
IceJavascriptHelpers = []
|
13
|
+
IceJavascriptHelpers = []
|
14
14
|
IceCoffeescriptHelpers = []
|
15
15
|
|
16
|
-
|
17
16
|
ActionView::Template.register_template_handler :coffeekup, Ice::Handlers::Coffeekup
|
18
|
-
ActionView::Template.register_template_handler :eco, Ice::Handlers::Eco
|
17
|
+
ActionView::Template.register_template_handler :eco, Ice::Handlers::Eco
|
18
|
+
|
19
|
+
require "action_controller"
|
20
|
+
Mime::Type.register "text/ice", :ice
|
21
|
+
|
22
|
+
ActionController::Renderers.add :ice do |object, options|
|
23
|
+
puts "oootototOOOOOOOOOO"
|
24
|
+
puts "rendering with #{object}"
|
25
|
+
puts "rendering to #{object.to_ice.to_json}"
|
26
|
+
self.send_data object.to_ice.to_json, :type => :ice
|
27
|
+
end
|
data/lib/ice/base_cube.rb
CHANGED
@@ -1,12 +1,22 @@
|
|
1
1
|
module Ice
|
2
2
|
class BaseCube
|
3
3
|
extend Ice::CubeAssociation
|
4
|
+
attr_reader :source
|
4
5
|
|
5
|
-
def
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
6
|
+
def to_ice
|
7
|
+
self
|
8
|
+
end
|
9
|
+
|
10
|
+
def id
|
11
|
+
@source.id
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.attribute_names
|
15
|
+
@@attribute_names ||= []
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.revealing(* attributes)
|
19
|
+
attribute_names.concat(attributes)
|
10
20
|
|
11
21
|
attributes.each do |attr|
|
12
22
|
define_method attr.to_sym do
|
@@ -15,31 +25,31 @@ module Ice
|
|
15
25
|
end
|
16
26
|
end
|
17
27
|
|
18
|
-
attr_reader :source
|
19
|
-
|
20
|
-
def to_ice
|
21
|
-
self
|
22
|
-
end
|
23
28
|
|
24
29
|
def to_hash
|
25
|
-
if
|
26
|
-
hash = {
|
27
|
-
|
28
|
-
|
30
|
+
if self.class.attribute_names.count > 0
|
31
|
+
hash = {}
|
32
|
+
([:id, :created_at, :updated_at] +
|
33
|
+
self.class.attribute_names).each do |method|
|
34
|
+
if @source.respond_to? method
|
35
|
+
hash[method] = source.send(method)
|
36
|
+
end
|
29
37
|
end
|
30
38
|
hash
|
31
39
|
else
|
32
|
-
@hash
|
40
|
+
@hash ||= @source.serializable_hash.to_ice
|
33
41
|
end
|
34
42
|
end
|
35
43
|
|
36
|
-
def
|
37
|
-
|
44
|
+
def to_json
|
45
|
+
to_hash.to_json
|
38
46
|
end
|
39
47
|
|
48
|
+
|
40
49
|
def initialize(source)
|
41
50
|
@source = source
|
42
|
-
|
51
|
+
|
52
|
+
unless self.class.attribute_names.count > 0
|
43
53
|
to_hash.each_key do |key|
|
44
54
|
unless self.respond_to? key.to_sym
|
45
55
|
self.class.send :define_method, key.to_sym do
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: ice
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.5.
|
5
|
+
version: 0.5.1
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Nate Kidwell
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2011-07-
|
13
|
+
date: 2011-07-03 00:00:00 -04:00
|
14
14
|
default_executable:
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|