diff --git a/README.md b/README.md index 4fb1a09..b8815f2 100644 --- a/README.md +++ b/README.md @@ -62,6 +62,8 @@ An article - Parameters are `{{Name|value}}` by position (the first bare value is `{{{1}}}`) or `{{Name|key=value}}`; a bar inside a `[[link|text]]` or another template belongs to that. - What is inside `` is left out when the template is included, and `` text is included without the tags, so a template page can carry its own documentation. - The template is looked up when the article is shown, so editing it changes every article that uses it. Only a template's approved version is used. +- A template can give table rows or cells (a text that starts with ``, ``, `` and so on), to be called between the `` tags of an article: `
{{Row|a|1}}{{Row|b|2}}
`. +- Limits, so one article cannot slow the board down: at most 500 template calls written in an article, 2000 calls and functions in all (including those inside templates), and about 500,000 characters of output. Past a limit the rest of the calls show "Too many templates" where they stand. - A template can include other templates, ten levels deep at most; a template that includes itself, directly or through another template, shows an error where the loop is (it cannot stop its own recursion with `{{#if:}}`, as on Wikipedia). A call to a template that does not exist is a red link to `Template:Name`. - The text of a template is parsed like article text, so it can use BBCode, `[[links]]`, headings and tables, and nothing an article could not. - **What links here** on a template page lists the articles that use it. diff --git a/docs/TODO/todo-wiki-markup.md b/docs/TODO/todo-wiki-markup.md index 78e08bc..0baf3da 100644 --- a/docs/TODO/todo-wiki-markup.md +++ b/docs/TODO/todo-wiki-markup.md @@ -158,8 +158,11 @@ out. Still to do: - Parser functions Wikipedia's templates use that are not here yet: `#titleparts`, `#rel2abs`, `#tag`, `formatnum`, `plural`, `gender`, `#invoke` (Lua, not planned), the `LOCAL...` and `REVISION...` magic words, and `#time` in the viewer's time zone and language. -- A cache of rendered articles, cleared when a template changes. Expansion runs on every view - today; add the cache only if a real board shows it is slow. +- A cache of rendered articles, cleared when a template changes. Expansion runs on every view. + Measured on a MySQL board: about 1 ms for each template call written in an article (a table of + 400 calls to a template took about 400 ms longer than the same table written out), one extra + query for the template pages however many calls there are, and at most 500 calls and 2000 + functions per article. Add the cache only if articles with hundreds of calls become common. - Template pages show `` and `` as text; a tidier template page view. - A template call holds other calls in its parameters three levels deep, and a default value holds one level of `{{template}}`; deeper nesting stays text. diff --git a/event/wikilink_listener.php b/event/wikilink_listener.php index 649a9ee..8dee37e 100644 --- a/event/wikilink_listener.php +++ b/event/wikilink_listener.php @@ -154,7 +154,9 @@ public function configure_wikilink($event) $template = $configurator->tags->add('WIKITEMPLATE'); $template->attributes->add('name'); $template->attributes->add('call'); - $template->template = ''; + // A