API · Miscellaneous

riot.version

The current version number as String: '3.13.2'

riot.settings.keepValueAttributes (default false)

>= v3.13

Riot removes by default all the falsy attribute expressions. However in some cases like for the <input> elements the value attribute should be always preserved see also issue/2629. By setting keepValueAttributes=true riot will no longer remove the value attributes even if its value is falsy.

riot.settings.keepValueAttributes = true

riot.settings.skipAnonymousTags (default true)

>= v3.2

In riot any new tag in a loop will create new riot tag instance. This will happen for custom tags and also for anonymous tags like <li each={ item in items }>{ item }</li>. In the last case riot will create lighter tag instances because they should not be observable and don’t need to be passed to the riot mixins. This will massively speed up the rendering process. However riot versions lower than 3.2 used to instanciate all the anonymous tags as full custom tags instances. With the skipAnonymousTags = false the anonymous tags will be no longer created as light tag instances and your app might become ~30% slower.

riot.settings.skipAnonymousTags = false

riot.settings.autoUpdate (default true)

>= v3.6

The update events will be automatically triggered in riot tags containing DOM handlers (like onclick) when an user will dispatch any of them. Setting the autoUpdate option to false you will disable this behavior and will need to manually trigger your tags updates.

riot.settings.autoUpdate = false

riot.settings.brackets (default { })

A global Riot setting to customize the start and end tokens of the expressions. For example

riot.settings.brackets = '[% %]'

let’s you write expressions <p>[% like_this %]</p>. The start and end is separated with a space character.

riot.settings.asyncRenderTimeout

It allows you to change the riot.renderAsync timeout (default 1000)

riot.settings.asyncRenderTimeout = 2000 // ms

riot.util.tmpl

Point to the internal riot template engine

riot.util.tmpl.errorHandler

Utility hook function to catch all the errors swallowed by the riot template engine

riot.util.tmpl.errorHandler = function (err) {
  console.error(err.message + ' in ' + err.riotData.tagName) // your error logic here
}

riot.util.styleManager

It’s the object that we use to append and create the custom tags css

riot.util.vdom

Expose the internal riot tags cache in order to query, debug, filter.. all the tags instances created

riot.tag('foo', '<p>{ msg }</p>', function() {
  this.msg = 'hi'
})
riot.mount('foo')
console.log(riot.vdom[0].msg) // 'hi'

riot.util.dom

Series of utility functions to update DOM nodes like $ to query nodes or addAttr to add attributes to a node

source code

riot.util.check

Series of helper functions needed for type checking

source code

riot.util.misc

Helper functions like extend to extend objects or each to loop arrays

source code

riot.util.tags

Methods needed to manage internally all the riot tags instances

source code