# if null use `title` instead
var summary_title: nullable String writable
- # Parent section of this section if any
- var parent: nullable TplSection
+ # CSS classes to apply on the section element
+ var css_classes = new Array[String]
+
+ # CSS classes to apply on the title heading element
+ var title_classes = new Array[String]
+
+ # Parent article/section if any
+ var parent: nullable TplSectionElt
init(id: String) do self.id = id
return parent.hlvl + 1
end
- # Render this section in the summary
- protected fun render_summary(parent: TplSummaryElt) is abstract
-
- # Is the section empty (no content at all)
- fun is_empty: Bool is abstract
-end
-
-# A HTML <section> element
-class TplSection
- super TplSectionElt
-
# Elements contained by this section
var children = new Array[TplSectionElt]
children.add child
end
- redef fun is_empty: Bool do return children.is_empty
+ # Is the section empty (no content at all)
+ fun is_empty: Bool do return children.is_empty
- redef fun render_summary(parent) do
+ # Render this section in the summary
+ fun render_summary(parent: TplSummaryElt) do
if is_empty then return
var title = summary_title
if title == null and self.title != null then title = self.title.write_to_string
end
parent.add_child entry
end
+end
+
+# A HTML <section> element
+class TplSection
+ super TplSectionElt
redef fun rendering do
- add "<section id='{id}'>"
+ add "<section id='{id}' class='{css_classes.join(" ")}'>"
if title != null then
var lvl = hlvl
- add "<h{lvl}>"
+ if lvl == 2 then title_classes.add "well well-sm"
+ add "<h{lvl} class='{title_classes.join(" ")}'>"
add title.as(not null)
add "</h{lvl}>"
end
# Content for this article
var content: nullable Streamable writable = null
+ var source_link: nullable Streamable writable = null
init with_content(id: String, title: Streamable, content: Streamable) do
with_title(id, title)
self.content = content
end
- # CSS classes to apply on the article title heading element
- var title_classes = new Array[String]
-
redef fun render_summary(parent) do
if is_empty then return
var title = summary_title
redef fun rendering do
if is_empty then return
- add "<article id='{id}'>"
+ add "<article id='{id}' class='{css_classes.join(" ")}'>"
+ if source_link != null then
+ add "<div class='source-link'>"
+ add source_link.as(not null)
+ add "</div>"
+ end
if title != null then
var lvl = hlvl
+ if lvl == 2 then title_classes.add "well well-sm"
add "<h{lvl} class='{title_classes.join(" ")}'>"
add title.as(not null)
add "</h{lvl}>"
if content != null then
add content.as(not null)
end
+ for child in children do
+ add child
+ end
add """</article>"""
end
var comment: nullable Streamable writable
# Namespace for this definition
- var namespace: Streamable writable
+ var namespace: nullable Streamable writable
# Location link to display
var location: nullable Streamable writable
private fun render_info do
add "<div class='info text-right'>"
- if comment == null then
- add "<span class=\"noComment\">no comment for </span>"
+ if namespace != null then
+ if comment == null then
+ add "<span class=\"noComment\">no comment for </span>"
+ end
+ add namespace.as(not null)
end
- add namespace
if location != null then
add " "
add location.as(not null)
init with_classes(classes: Array[String]) do self.css_classes = classes
+ fun is_empty: Bool do return elts.is_empty
+
redef fun rendering do
if elts.is_empty then return
add "<ul class='{css_classes.join(" ")}'>"