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

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