How to use the riot/riot.js.tag function in riot

To help you get started, we’ve selected a few riot examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ilearnio / riot-ssr / test / tags / mount.js View on Github external
var riot = require('riot/riot.js')
require('./async')

module.exports = riot.tag('mount', '<div></div>', function (opts) {
  // It's important that the child tag will contain a proper
  // `this.parent` or `this.opts.parent` property which will
  // reference to the current tag
  var _opts = { parent: this }

  riot.mount(this.target, 'mount-child', _opts)[0]
})

riot.tag('mount-child', '{value}', function (opts) {
  var self = this

  self.value = ''

  self.asyncStart()
  setTimeout(function () {
    self.value = 'ok'
    self.update()
    self.asyncEnd()
  }, 10)
})
github ilearnio / riot-ssr / test / tags / mount.js View on Github external
var riot = require('riot/riot.js')
require('./async')

module.exports = riot.tag('mount', '<div></div>', function (opts) {
  // It's important that the child tag will contain a proper
  // `this.parent` or `this.opts.parent` property which will
  // reference to the current tag
  var _opts = { parent: this }

  riot.mount(this.target, 'mount-child', _opts)[0]
})

riot.tag('mount-child', '{value}', function (opts) {
  var self = this

  self.value = ''

  self.asyncStart()
  setTimeout(function () {
    self.value = 'ok'
github ilearnio / riot-ssr / test / tags / long-running.js View on Github external
var riot = require('riot/riot.js')

module.exports = riot.tag('long-running', '{value}', function (opts) {
  var self = this
  self.value = ''
  self.asyncStart()
  setTimeout(function () {
    self.value = opts.value || 'ok'
    self.update()
    self.asyncEnd()
  }, 500)
})
github ilearnio / riot-ssr / test / tags / async.js View on Github external
var riot = require('riot/riot.js')

module.exports = riot.tag('async', '{value}', function (opts) {
  var self = this
  self.value = ''
  self.asyncStart()
  setTimeout(function () {
    self.value = 'ok'
    self.update()
    self.asyncEnd()
  }, 10)
})
github ilearnio / riot-ssr / test / tags / nested.js View on Github external
var riot = require('riot/riot.js')
require('./sync')
require('./async')

module.exports = riot.tag('nested', '{value}',
  function (opts) {
    var self = this
    self.value = ''
    self.asyncStart()
    setTimeout(function () {
      self.value = 'ok'
      self.update()
      self.asyncEnd()
    }, 10)
  }
)
github ilearnio / riot-ssr / test / tags / async-chain.js View on Github external
var riot = require('riot/riot.js')

module.exports = riot.tag('async-chain', '{value}', function (opts) {
  var self = this

  self.asyncStart()
  self.asyncEnd()

  self.asyncStart()
  self.asyncEnd()

  self.asyncStart()
  setTimeout(function () {
    self.asyncEnd()

    self.asyncStart()
    setTimeout(function () {
      self.value = 'ok'
      self.update()
github ilearnio / riot-ssr / test / tags / sync.js View on Github external
var riot = require('riot/riot.js')

module.exports = riot.tag('sync', '{value}', function (opts) {
  this.value = 'ok'
})