cuhaml-contrib 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: e39d8b4bbb6c5d92bc73daed7b18a6e2a2fbe25d
4
- data.tar.gz: 84ab878c57c501f804e263ddc33e6181f68906b1
3
+ metadata.gz: 14551ff3cb353c94555921cad7969c7ec9577f2b
4
+ data.tar.gz: 39dc686bd610e6e23ed328d5fea56eec5dc736bf
5
5
  SHA512:
6
- metadata.gz: a3b5d2c54c63092febe83bab9e2eacbec78ed8424ac8ab29e8253292d0cbd4f0c520dbaec304a7a3ec50760fff35a6ecedcf25e5aab6417701c3b182c17417fd
7
- data.tar.gz: 0a6681782f142c3f8ed836c4d310c36626487b45d9f42967dfae57e519a14219997959b30397145bd34c876ed157d736254f28d8b9e21b0f7f2c02196f094cdb
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 a content in a view
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 a content for a given symbol
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
@@ -1,5 +1,5 @@
1
1
  module Cuhaml
2
2
  module Contrib
3
- VERSION = "0.0.1"
3
+ VERSION = "0.0.2"
4
4
  end
5
5
  end
@@ -20,13 +20,21 @@ module Cuhaml::Contrib
20
20
  end
21
21
  end
22
22
 
23
- it "yields the given block" do
23
+ let(:body) do
24
24
  _, _, body = Cuba.call({ "PATH_INFO" => "/", "SCRIPT_NAME" => "/" })
25
- body.first.must_match /alpha\s+beta\s+gamma\s+/
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
@@ -2,3 +2,5 @@
2
2
  - yield_for :not
3
3
  beta
4
4
  = content
5
+ - if content_for?(:not)
6
+ omega
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.1
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-08-04 00:00:00.000000000 Z
11
+ date: 2013-10-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: haml