Browse Source

organize code for router template

master
Marek Piasecki 1 year ago
parent
commit
b5b2586c7f
  1. 17
      src/helpers.imba
  2. 1
      src/index.js
  3. 29
      src/main.imba
  4. 11
      src/router.imba

17
src/helpers.imba

@ -0,0 +1,17 @@
import compact from 'lodash.compact'
import fromPairs from 'lodash.frompairs'
import chunk from 'lodash.chunk'
import includes from 'lodash.includes'
import reject from 'lodash.reject'
import toPairs from 'lodash.topairs'
import flatten from 'lodash.flatten'
export helpers = {
compact: compact
fromPairs: fromPairs
chunk: chunk
includes: includes
reject: reject
toPairs: toPairs
flatten: flatten
}

1
src/index.js

@ -1,2 +1 @@
import "pro-router/standalone"
import "./main.imba"

29
src/main.imba

@ -1,31 +1,4 @@
import "./router_tag.imba"
import compact from 'lodash.compact'
import fromPairs from 'lodash.frompairs'
import chunk from 'lodash.chunk'
import includes from 'lodash.includes'
import reject from 'lodash.reject'
import toPairs from 'lodash.topairs'
import flatten from 'lodash.flatten'
let helpers =
compact: compact
fromPairs: fromPairs
chunk: chunk
includes: includes
reject: reject
toPairs: toPairs
flatten: flatten
# EDIT BELOW
R.init(helpers: helpers, root: 'home', render: imba.commit)
tag view-home
<self><h1> 'Imba2 on Pro Router is working...'
tag view-not_found
<self><h1> "Page not found :("
import './router.imba'
tag App
<self[d:bbox]>

11
src/router.imba

@ -0,0 +1,11 @@
import "pro-router/standalone" # standalone operates on "/#/" hash style url; for regular "/" url use: "pro-router/router"
import "./router_tag.imba"
import { helpers } from "./helpers.imba"
R.init helpers: helpers, root: 'home', render: imba.commit
tag view-home
<self><h1> 'Imba2 on Pro Router is working...'
tag view-not_found
<self><h1> "Page not found :("
Loading…
Cancel
Save