From: Jean Privat Date: Wed, 11 Nov 2015 16:14:07 +0000 (-0500) Subject: nitiwiki: add `WikiEntry::a_from` to factorize the creation of links to pages. X-Git-Tag: v0.8~89^2~6 X-Git-Url: http://nitlanguage.org?ds=sidebyside nitiwiki: add `WikiEntry::a_from` to factorize the creation of links to pages. Signed-off-by: Jean Privat --- diff --git a/contrib/nitiwiki/src/wiki_links.nit b/contrib/nitiwiki/src/wiki_links.nit index efb9f78..a49edfb 100644 --- a/contrib/nitiwiki/src/wiki_links.nit +++ b/contrib/nitiwiki/src/wiki_links.nit @@ -102,6 +102,17 @@ redef class WikiEntry return res end + # A relative hyperlink to `self` from the page `context`. + # + # If `text` is not given, `title` will be used instead. + fun a_from(context: WikiEntry, text: nullable Text): Writable + do + var title = title.html_escape + if text == null then text = title else text = text.html_escape + var href = href_from(context) + return """{{{text}}}""" + end + redef fun render do super if not is_dirty and not wiki.force_render then return