Permalink
Browse files

Variables for use in Mustache templates.

Added:

*   `docs?`:    True if `docs` contains text of any sort, False if
                it's empty.

*   `code?`:    True if `code` contains text of any sort, False if
                it's empty.

*   `empty?`:   True if both `code` and `docs` are empty.  False
                otherwise.

*   `header?`:  True if `docs` contains _only_ a HTML header.  False
                otherwise.
  • Loading branch information...
1 parent bb8fcb9 commit bb9b167b13fe0f6fbf6a59547919eed47b9c3476 @mikewest mikewest committed Oct 17, 2010
Showing with 9 additions and 3 deletions.
  1. +9 −3 lib/rocco/layout.rb
View
@@ -18,9 +18,15 @@ def sections
num = 0
@doc.sections.map do |docs,code|
{
- :docs => docs,
- :code => code,
- :num => (num += 1)
+ :docs => docs,
+ :docs? => !docs.empty?,
+ :header? => /^<h.>.+<\/h.>$/.match( docs ),
+
+ :code => code,
+ :code? => !code.empty?,
+
+ :empty? => ( code.empty? && docs.empty? ),
+ :num => (num += 1)
}
end
end

0 comments on commit bb9b167

Please sign in to comment.