gara 0.1.2 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c016aca52f2c28e4738a75014ba0d1f43d744996
4
- data.tar.gz: 3a053f34302ff0943767f6876d38c0704bf1edbe
3
+ metadata.gz: c2ac74cf48840c8830258afe2ea3733f4f39240c
4
+ data.tar.gz: 4bd67171c9ac39e2b4b65b1a4ba1fa4bc653ad83
5
5
  SHA512:
6
- metadata.gz: 8c821cfb8c7c785001a8df9d4bc56acc0b737ec7d68a58b61074a4e1ba0f6e613b60951c015ebf20e941269c08fa9e11cfba238d8f92364391315e54e886e4f7
7
- data.tar.gz: c7f69e1580ebb2527132b18c741f4b45c656b531398a135cd0b433561ab9c29b6156746d12aad27f65d59149405a9095b956e65499f56ccd3902b270b3f1bf5f
6
+ metadata.gz: 7743c123c5bb7cdeeea973f41b6a1b2b49ec4b5ea5e77deb4503828ab1123f280c7e768f7a0d64be4549ea7f67c0b6ed4be3bf63000c86419321316767952bb8
7
+ data.tar.gz: f2a3f4b3afe8b3d0a1e7cfc628cfb26c4ef21a25a2c850fc2ad3ea83764f0082a1d4e04249e4f9fe9d34b753d9c049f4c2fe3d70344856be56344d287c6592c4
data/README.md CHANGED
@@ -22,7 +22,7 @@ Change your template to look like this.
22
22
  csrf_meta_tags
23
23
  }
24
24
  body {
25
- yield
25
+ self << yield
26
26
  javascript_include_tag "application"
27
27
  }
28
28
  }
@@ -12,15 +12,15 @@ module Gara
12
12
  end
13
13
 
14
14
 
15
- def initialize(view_context, emitter = Html5Emitter.new)
15
+ def initialize(view_context, emitter)
16
16
  @emitter = emitter
17
17
  view_context.instance_variable_set(:@gara_delegate, emitter)
18
18
  view_context.extend(emitter.registered_methods)
19
19
  yield if block_given?
20
20
  end
21
21
 
22
- def to_html
23
- emitter.to_html
22
+ def render
23
+ @emitter.emit
24
24
  end
25
25
 
26
26
  end
@@ -45,7 +45,7 @@ module Gara
45
45
  return TagMethods
46
46
  end
47
47
 
48
- def to_html
48
+ def emit
49
49
  nodes = @doc.children
50
50
  if nodes.length.eql?(1) && nodes.first.name.eql?("html")
51
51
  # necessary to include doctype - TODO: avoid calling to_html twice
@@ -0,0 +1,7 @@
1
+ module Gara
2
+ module Renderer
3
+ def render context, emitter = Html5Emitter.new, &block
4
+ Gara::Delegator.new(context, emitter, &block).render
5
+ end
6
+ end
7
+ end
@@ -6,7 +6,7 @@ module Gara
6
6
  end
7
7
 
8
8
  def call(template)
9
- %Q(Gara::Delegator.new(self) { #{template.source} }.to_html)
9
+ %Q(Gara.render(self) { #{template.source} })
10
10
  end
11
11
 
12
12
  end
data/lib/gara/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Gara
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.4"
3
3
  end
data/lib/gara.rb CHANGED
@@ -2,7 +2,10 @@ module Gara
2
2
  require 'gara/template/handler'
3
3
  require 'gara/delegator'
4
4
  require 'gara/html5_emitter'
5
+ require 'gara/renderer'
6
+ extend Renderer
5
7
  if defined?(Rails)
6
8
  ::ActionView::Template.register_template_handler :gara, Gara::Template::Handler
7
9
  end
10
+
8
11
  end
@@ -1,4 +1,5 @@
1
1
  class HelloController < ApplicationController
2
2
  def show
3
+ @hello = "Hi there"
3
4
  end
4
5
  end
@@ -1,2 +1,2 @@
1
- h1 "Hello"
1
+ h1 @hello
2
2
  p 'Find me in app/views/hello/show.html.gara'
@@ -1593,3 +1593,9 @@ Started GET "/hello" for 127.0.0.1 at 2014-08-12 16:15:09 +0800
1593
1593
  Processing by HelloController#show as HTML
1594
1594
  Rendered hello/show.html.gara within layouts/application (1.0ms)
1595
1595
  Completed 200 OK in 40ms (Views: 39.6ms)
1596
+
1597
+
1598
+ Started GET "/hello" for 127.0.0.1 at 2014-08-13 04:19:27 +0800
1599
+ Processing by HelloController#show as HTML
1600
+ Rendered hello/show.html.gara within layouts/application (1.6ms)
1601
+ Completed 200 OK in 37ms (Views: 37.0ms)