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 +4 -4
- data/lib/lithium.rb +1 -2
- data/lib/lithium/modules/template.rb +30 -0
- data/lib/lithium/version.rb +1 -1
- metadata +3 -4
- data/lib/lithium/modules/templates/erb.rb +0 -11
- data/lib/lithium/modules/templates/slim.rb +0 -19
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a9a47f71420cbd144d940d513b2f1569f348a399
|
4
|
+
data.tar.gz: 956094a0d4327dadc0f26f2ab5acefc305d49e45
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ebedb81f9c447364a9cb331d02d4e3b463bfe590bb44c65d1ee98e8b77ac2434c7cfb58538c3b61b02d631266b0e38e099c3c7de31c99c0e88715f19932ee330
|
7
|
+
data.tar.gz: 150447d52ba82931ce4c226e1ae2b0b4af33b47b20c6e74c1f8fc50622a4de06db68009c948a974dae1231aafe6cdc9d9367badb8b4435f71c27f0ae4d869bf8
|
data/lib/lithium.rb
CHANGED
@@ -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
|
data/lib/lithium/version.rb
CHANGED
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.
|
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-
|
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/
|
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,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
|