cuhaml-contrib 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/cuhaml/contrib/content_for.rb +14 -2
- data/lib/cuhaml/contrib/version.rb +1 -1
- data/spec/content_for_spec.rb +10 -2
- data/spec/views/layout.haml +2 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 14551ff3cb353c94555921cad7969c7ec9577f2b
|
4
|
+
data.tar.gz: 39dc686bd610e6e23ed328d5fea56eec5dc736bf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3047011b6d77130d449082dd8333476138faa3de78ddb6533e5aefb7c0ed2c662524f2bb99b9cd175d66990ce885013661d669248789f050bd8de2303a6696de
|
7
|
+
data.tar.gz: 6b17c8649acd39b3b83978e4f56e19a13fab7a374858637049c48b837b1297dbba75c2622f1f5557b3985ad82d91b9a0b67e9d1ea25f86255175e7479385d6b1
|
@@ -7,7 +7,7 @@ module Cuhaml
|
|
7
7
|
app.settings[:render][:template_engine] = "haml"
|
8
8
|
end
|
9
9
|
|
10
|
-
# Public: yields
|
10
|
+
# Public: yields content in a view
|
11
11
|
#
|
12
12
|
# symbol - The symbol to be searched
|
13
13
|
#
|
@@ -18,7 +18,7 @@ module Cuhaml
|
|
18
18
|
haml_concat(content_blocks[symbol].join)
|
19
19
|
end
|
20
20
|
|
21
|
-
# Public: Sets
|
21
|
+
# Public: Sets the content for a given symbol
|
22
22
|
#
|
23
23
|
# symbol - The symbol key
|
24
24
|
# &block - Block to be called
|
@@ -32,6 +32,18 @@ module Cuhaml
|
|
32
32
|
content_blocks[symbol] << capture_haml(&block)
|
33
33
|
end
|
34
34
|
|
35
|
+
# Public: return true if content has been provided for the given symbol, false otherwise
|
36
|
+
#
|
37
|
+
# symbol - The symbol to be searched
|
38
|
+
#
|
39
|
+
# Examples:
|
40
|
+
#
|
41
|
+
# <% if content_for? :menu %>
|
42
|
+
# <% end %>
|
43
|
+
def content_for?(symbol)
|
44
|
+
!content_blocks[symbol].empty?
|
45
|
+
end
|
46
|
+
|
35
47
|
private
|
36
48
|
|
37
49
|
# Private: Hash of arrays to store content blocks
|
data/spec/content_for_spec.rb
CHANGED
@@ -20,13 +20,21 @@ module Cuhaml::Contrib
|
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
23
|
-
|
23
|
+
let(:body) do
|
24
24
|
_, _, body = Cuba.call({ "PATH_INFO" => "/", "SCRIPT_NAME" => "/" })
|
25
|
-
body.first
|
25
|
+
body.first
|
26
|
+
end
|
27
|
+
|
28
|
+
it "yields the given block" do
|
29
|
+
body.must_match /alpha\s+beta\s+gamma\s+/
|
26
30
|
end
|
27
31
|
|
28
32
|
it "sets the default template engine" do
|
29
33
|
Cuba.settings[:render][:template_engine].must_equal "haml"
|
30
34
|
end
|
35
|
+
|
36
|
+
it "outputs content conditionally" do
|
37
|
+
body.wont_include "omega"
|
38
|
+
end
|
31
39
|
end
|
32
40
|
end
|
data/spec/views/layout.haml
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cuhaml-contrib
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Cristian Rasch
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-10-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: haml
|