lithium 0.0.2 → 0.0.3

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: 1d20b742247809e17b6784aeae96cac85981cedc
4
- data.tar.gz: b6009b546724ffde5b29820e23d6ecfa57862f69
3
+ metadata.gz: a9a47f71420cbd144d940d513b2f1569f348a399
4
+ data.tar.gz: 956094a0d4327dadc0f26f2ab5acefc305d49e45
5
5
  SHA512:
6
- metadata.gz: 909d65c818d90627ca6279187225b2d31f48187bcc82a0c7dcd1fcb22355382a77a4cd7aa5c5df22ab6bbad6c3a45c06724a56eea3217cb6a9b06c41666f0e9c
7
- data.tar.gz: 0ca0144f25c8f229de6898fa0fad1bbd815c3b7e698b5d997be48a9f461225b20e611e66edb70814aa04a91e181889a09ab702aa138b1adbafb1988ab690ce8a
6
+ metadata.gz: ebedb81f9c447364a9cb331d02d4e3b463bfe590bb44c65d1ee98e8b77ac2434c7cfb58538c3b61b02d631266b0e38e099c3c7de31c99c0e88715f19932ee330
7
+ data.tar.gz: 150447d52ba82931ce4c226e1ae2b0b4af33b47b20c6e74c1f8fc50622a4de06db68009c948a974dae1231aafe6cdc9d9367badb8b4435f71c27f0ae4d869bf8
@@ -1,6 +1,5 @@
1
1
  # Modules
2
- require 'lithium/modules/templates/slim'
3
- require 'lithium/modules/templates/erb'
2
+ require 'lithium/modules/template'
4
3
 
5
4
  require 'lithium/base'
6
5
  require 'lithium/version'
@@ -0,0 +1,30 @@
1
+ require 'tilt'
2
+ require 'slim'
3
+ module Lithium
4
+ module Modules
5
+ module Template
6
+ def self.default_layout layout = nil
7
+ "layouts/layout.slim" if layout.nil?
8
+ end
9
+
10
+ def render template, locals = {}, options = {}, &block
11
+ template_cache.fetch(template) do
12
+ ::Slim::Template.new(template, options)
13
+ end.render(self, locals, &block)
14
+ end
15
+
16
+ def view *args
17
+ options = args[1]
18
+ layout = options[:layout].nil? ? "layouts/layout.slim" : options[:layout]
19
+
20
+ render "#{layout}" do
21
+ render *args
22
+ end
23
+ end
24
+
25
+ def template_cache
26
+ Thread.current[:templates_cache] ||= Tilt::Cache.new
27
+ end
28
+ end
29
+ end
30
+ end
@@ -1,3 +1,3 @@
1
1
  module Lithium
2
- VERSION = '0.0.2'
2
+ VERSION = '0.0.3'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lithium
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sedat CIFTCI
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-04-26 00:00:00.000000000 Z
11
+ date: 2015-04-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rack
@@ -63,8 +63,7 @@ files:
63
63
  - README.md
64
64
  - lib/lithium.rb
65
65
  - lib/lithium/base.rb
66
- - lib/lithium/modules/templates/erb.rb
67
- - lib/lithium/modules/templates/slim.rb
66
+ - lib/lithium/modules/template.rb
68
67
  - lib/lithium/version.rb
69
68
  homepage: https://github.com/amerobin/lithium
70
69
  licenses:
@@ -1,11 +0,0 @@
1
- module Lithium
2
- module Modules
3
- module Templates
4
- module Erb
5
- def render template
6
- ERB.new(File.open(template).read).result(binding)
7
- end
8
- end
9
- end
10
- end
11
- end
@@ -1,19 +0,0 @@
1
- require 'tilt'
2
- require 'slim'
3
- module Lithium
4
- module Modules
5
- module Templates
6
- module Slim
7
- def render template, locals = {}, options = {}, &block
8
- template_cache.fetch(template) do
9
- ::Slim::Template.new(template, options)
10
- end.render(self, locals, &block)
11
- end
12
-
13
- def template_cache
14
- Thread.current[:templates_cache] ||= Tilt::Cache.new
15
- end
16
- end
17
- end
18
- end
19
- end