Browse Source

make router tag universal, independant on pro-router

master
Marek Piasecki 6 years ago
parent
commit
13d86a3619
  1. 6
      index.imba
  2. 16
      router/router.imba
  3. 23
      router_tag.imba

6
index.imba

@ -0,0 +1,6 @@
global:Router = require('pro-router')
require './router/router'
require './ref/ref'
require './switch/switch'
require './not_found/not_found'

16
router/router.imba

@ -0,0 +1,16 @@
tag router
prop component watch: yes
def setup
@component = null
@cache = {}
def componentDidSet val, prev
removeChild(prev) if prev
appendChild(val) if val
self
def render
component = @cache[@data] ||= Imba.createElement(@data,null,null,self)
component.end

23
router_tag.imba

@ -1,23 +0,0 @@
global:Router = require('pro-router')
require './ref/ref'
require './switch/switch'
require './not_found/not_found'
tag router
prop component watch: yes
def setup
@r = R
@component = null
@cache = {}
def componentDidSet val, prev
removeChild(prev) if prev
appendChild(val) if val
self
def render
var view = @data || @r:view
component = @cache[view] ||= Imba.createElement(view,null,null,self)
component.end
Loading…
Cancel
Save