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.
This commit is contained in:
Mike West 2010-10-17 13:16:45 +02:00
parent bb8fcb9ef0
commit bb9b167b13

View File

@ -18,9 +18,15 @@ class Rocco::Layout < Mustache
num = 0 num = 0
@doc.sections.map do |docs,code| @doc.sections.map do |docs,code|
{ {
:docs => docs, :docs => docs,
:code => code, :docs? => !docs.empty?,
:num => (num += 1) :header? => /^<h.>.+<\/h.>$/.match( docs ),
:code => code,
:code? => !code.empty?,
:empty? => ( code.empty? && docs.empty? ),
:num => (num += 1)
} }
end end
end end