tilt-mote 0.0.1 → 0.0.2

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: aab6268effc5af6bc6a4f6c5089916f0185612e9
4
- data.tar.gz: 0d4d8f1ddc27b3d19423db0fff458b3f13ff9229
3
+ metadata.gz: 2319a7544f823994355afe5b65d6ca067c9a1b27
4
+ data.tar.gz: fa8e65fdcf3f313a7acbea4462586387dc755100
5
5
  SHA512:
6
- metadata.gz: fac9cef22b5f7ffa207fda127cda2b811012abc3ba03fe517da237b0e4e043f9252caecaca992f3483aaf97c8d35c66286e393b20434f68a80209ec7eee23b8d
7
- data.tar.gz: e2c1ec8959d56f6dac13e208f4b4a36d969403c26a7ac2c73cadb6be1d540af2eb818b3e5d04c7cc4e0893179c7685939c145ba191362d2cdf31717d293c64fa
6
+ metadata.gz: 8074add34e08ef966a171a4eb1ff5009dc250accbf6b8f394322cabd1898e115b9c162d98c945824e3152cbeabe73be7ffc2a71aa859902dd0621670ea948a85
7
+ data.tar.gz: ce52c8e1a23da1d28b2a4694677c8dc138af442079b86c6734b0b530dfd64217b6e9865606e82150167e2890aae5119fdce8bd2af9bf9564e2bd7bf6b0e69d48
data/.gems CHANGED
@@ -1,3 +1,5 @@
1
1
  tilt -v 2.0.1
2
2
  mote -v 1.1.2
3
3
  cutest -v 1.2.1
4
+ cuba -v 3.3.0
5
+ rack-test -v 0.6.2
data/lib/cuba/mote.rb ADDED
@@ -0,0 +1,31 @@
1
+ # borrowed from:
2
+ # https://github.com/harmoni-io/mote-render/blob/master/lib/mote/render.rb
3
+ module Mout
4
+ module Render
5
+ include ::Mote::Helpers
6
+
7
+ def self.setup(app)
8
+ app.settings[:template_engine] = "mote"
9
+ end
10
+
11
+ def render(template, locals = {}, layout = settings[:render][:layout])
12
+ res.write(view(template, locals, layout))
13
+ end
14
+
15
+ def view(template, locals = {}, layout = settings[:render][:layout])
16
+ partial(layout, locals.merge(content: partial(template, locals)))
17
+ end
18
+
19
+ def partial(template, locals = {})
20
+ mote(mote_path(template), locals.merge(app: self), TOPLEVEL_BINDING)
21
+ end
22
+
23
+ def mote_path(template)
24
+ if template.end_with?(".mote")
25
+ template
26
+ else
27
+ File.join(settings[:render][:views], "#{template}.mote")
28
+ end
29
+ end
30
+ end
31
+ end
data/test/test_helper.rb CHANGED
@@ -1,2 +1,24 @@
1
1
  require 'cutest'
2
+ require 'cuba/test'
3
+ require 'cuba/render'
2
4
  require File.expand_path("../lib/tilt/mote", File.dirname(__FILE__))
5
+ require File.expand_path("../lib/cuba/mote", File.dirname(__FILE__))
6
+
7
+ Cuba.plugin(Cuba::Render)
8
+ Cuba.plugin(Mout::Render)
9
+
10
+ Cuba.settings[:render][:views] = "./test/views"
11
+
12
+ Cuba.define do
13
+ on "partial" do
14
+ res.write partial("dashboard")
15
+ end
16
+
17
+ on "view" do
18
+ res.write view("dashboard", title: "Test")
19
+ end
20
+
21
+ on "render" do
22
+ render("dashboard", title: "Test")
23
+ end
24
+ end
@@ -1,10 +1,44 @@
1
1
  require_relative 'test_helper'
2
2
 
3
3
  test 'renders a template' do
4
- template = Tilt.new('test/fixtures/template.mote')
4
+ template = Tilt.new('test/fixtures/template.mote')
5
5
 
6
6
  result = template.render(nil, what: 'things')
7
7
 
8
- assert result.strip == \
9
- "If you cannot do great things, do small things in a great way."
8
+ assert result ==
9
+ "If you cannot do great things, do small things in a great way.\n"
10
+ end
11
+
12
+ scope do
13
+ setup do
14
+ <<-HTML
15
+ <!DOCTYPE html>
16
+ <html>
17
+ <head>
18
+ <title>Test</title>
19
+ </head>
20
+ <body>
21
+ <p>Res, non verba.</p>\n
22
+ </body>
23
+ </html>
24
+ HTML
25
+ end
26
+
27
+ test "partial renders a template without the default layout" do
28
+ get "/partial"
29
+
30
+ assert last_response.body["<p>Res, non verba.</p>"]
31
+ end
32
+
33
+ test "view renders a template with a default layout" do |tmpl|
34
+ get "/view"
35
+
36
+ assert last_response.body[tmpl]
37
+ end
38
+
39
+ test "render shortcut renders a template with a default layout" do |tmpl|
40
+ get "/render"
41
+
42
+ assert last_response.body[tmpl]
43
+ end
10
44
  end
@@ -0,0 +1 @@
1
+ <p>Res, non verba.</p>
@@ -0,0 +1,9 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>{{ title }}</title>
5
+ </head>
6
+ <body>
7
+ {{ content }}
8
+ </body>
9
+ </html>
data/tilt-mote.gemspec CHANGED
@@ -4,10 +4,10 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
 
5
5
  Gem::Specification.new do |spec|
6
6
  spec.name = "tilt-mote"
7
- spec.version = "0.0.1"
7
+ spec.version = "0.0.2"
8
8
  spec.authors = ["Horacio Bertorello"]
9
9
  spec.email = ["syrii@msn.com"]
10
- spec.summary = "User Mote templates with Tilt."
10
+ spec.summary = "Use Mote templates with Tilt."
11
11
  spec.homepage = "https://github.com/svankmajer/tilt-mote"
12
12
  spec.license = "MIT"
13
13
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tilt-mote
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Horacio Bertorello
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-09-17 00:00:00.000000000 Z
11
+ date: 2014-09-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mote
@@ -50,10 +50,13 @@ files:
50
50
  - LICENSE
51
51
  - README.md
52
52
  - Rakefile
53
+ - lib/cuba/mote.rb
53
54
  - lib/tilt/mote.rb
54
55
  - test/fixtures/template.mote
55
56
  - test/test_helper.rb
56
57
  - test/tilt-mote_test.rb
58
+ - test/views/dashboard.mote
59
+ - test/views/layout.mote
57
60
  - tilt-mote.gemspec
58
61
  homepage: https://github.com/svankmajer/tilt-mote
59
62
  licenses:
@@ -78,5 +81,5 @@ rubyforge_project:
78
81
  rubygems_version: 2.4.1
79
82
  signing_key:
80
83
  specification_version: 4
81
- summary: User Mote templates with Tilt.
84
+ summary: Use Mote templates with Tilt.
82
85
  test_files: []