Getting started with Kuma

  • Revision slug: Project:Getting_started_with_Kuma
  • Revision title: Getting started with Kuma
  • Revision id: 39044
  • Created:
  • Creator: groovecoder
  • Is current revision? No
  • Comment one or more formatting changes

Revision Content

{{ draft() }}

This article will cover the differences between the current MindTouch wiki that powers MDN and the new Kuma wiki that we will be switching to very soon. The Kuma developers will be giving us an initial list of the big differences, and the writing team will build it out as we experiment with the new software. Stay tuned!

Things that work differently

New features of Kuma

KumaScript

Caching

KumaScript templates are heavily cached to improve performance. To clear a page's template cache, use a "Force refresh" - i.e., a request with Cache Control: no-cache.

Syntax

  • All template calls now use the syntax:
    {{ templateName(arguments) }}
  • No more <span class="script">
  • No more template. nor wiki.template prefixing
  • No more template({name}[, arguments]) syntax
  • Arguments must be quoted - e.g., bug(123456) becomes bug("123456")

Templates

Templates are conventionally named with a slug starting with Template:

Templates may be included in pages with {{ template_name }}.

Templates may be passed arguments in parentheses like {{ template_name(1, 2) }}.

Templates may be included in other templates.

Libraries

Templates can act as libraries that output nothing, but export functions for other templates. E.g.,

Template:math_lib

{%
exports.add = function(a, b) {
  return a+b;
};
%}

Template:math source

{% var test_lib = require('test_lib'); %}
{%= test_lib.add(1,2) %}

Template:math output

3
Auto-loaded Libraries

Some libraries are automatically loaded in all templates. (The list of auto-loaded libraries is controlled server-side.) Auto-loaded libraries use a different syntax than standard libraries. E.g.,

Template:String

{%
module.exports = buildAPI({
    StartsWith: function (str, sub_str) {
        return (''+str).indexOf(sub_str) === 0;
    },
});
%}

Template:Using-String

{% String.StartsWith('-moz') %}

Things Kuma can't do

See also

Revision Source

<p>{{ draft() }}</p>
<p>This article will cover the differences between the current MindTouch wiki that powers MDN and the new Kuma wiki that we will be switching to very soon. The Kuma developers will be giving us an initial list of the big differences, and the writing team will build it out as we experiment with the new software. Stay tuned!</p>
<h2>Things that work differently</h2>
<h2>New features of Kuma</h2>
<h3>KumaScript</h3>
<h4>Caching</h4>
<p>KumaScript templates are heavily cached to improve performance. To clear a page's template cache, use a "Force refresh" - i.e., a request with <code>Cache Control: no-cache</code>.</p>
<h4>Syntax</h4>
<ul> <li>All template calls now use the syntax:<br> <span class="nowiki"> <code> {{ templateName(arguments) }}</code></span></li> <li>No more <code>&lt;span class="script"&gt;</code></li> <li>No more <code>template.</code> nor <code>wiki.template</code> prefixing</li> <li>No more <code>template({name}[, arguments])</code> syntax</li> <li>Arguments must be quoted - e.g., <code>bug(123456)</code> becomes <code>bug("123456")</code></li>
</ul>
<h4>Templates</h4>
<p>Templates are conventionally named with a slug starting with <code>Template:</code></p>
<p>Templates may be included in pages with <span class="nowiki"><code>{{ template_name }}</code></span>.</p>
<p>Templates may be passed arguments in parentheses like <span class="nowiki"><code>{{ template_name(1, 2) }}</code></span>.</p>
<p>Templates may be included in other templates.</p>
<h4>Libraries</h4>
<p>Templates can act as libraries that output nothing, but export functions for other templates. E.g.,</p>
<p>Template:math_lib</p>
<pre><code>{%
</code>exports.add = function(a, b) {
  return a+b;
};
%}
</pre>
<p>Template:math source</p>
<pre>{% var test_lib = require('test_lib'); %}
{%= test_lib.add(1,2) %}
</pre>
<p>Template:math output</p>
<pre>3
</pre>
<h5>Auto-loaded Libraries</h5>
<p>Some libraries are automatically loaded in all templates. (The list of auto-loaded libraries is controlled server-side.) Auto-loaded libraries use a different syntax than standard libraries. E.g.,</p>
<p>Template:String</p>
<pre>{%
module.exports = buildAPI({
    StartsWith: function (str, sub_str) {
        return (''+str).indexOf(sub_str) === 0;
    },
});
%}
</pre>
<p>Template:Using-String</p>
<pre>{% String.StartsWith('-moz') %}
</pre>
<h2>Things Kuma can't do</h2>
<h2>See also</h2>
<ul> <li><a href="/Project:en/Introduction_to_KumaScript" title="/Project:en/Introduction to KumaScript">Introduction to KumaScript</a></li> <li><a href="/Project:en/KumaScript_reference" title="Project:en/KumaScript reference">KumaScript reference</a></li> <li><a class="link-https" href="https://wiki.mozilla.org/MDN/Kuma" title="https://wiki.mozilla.org/MDN/Kuma">Kuma wiki</a></li>
</ul>
Revert to this revision