From b5b2586c7f495d159585c490f73dfc82eb24ac93 Mon Sep 17 00:00:00 2001 From: Marek Piasecki Date: Sun, 15 Jan 2023 15:47:13 +0100 Subject: [PATCH] organize code for router template --- src/helpers.imba | 17 +++++++++++++++++ src/index.js | 1 - src/main.imba | 29 +---------------------------- src/router.imba | 11 +++++++++++ 4 files changed, 29 insertions(+), 29 deletions(-) create mode 100644 src/helpers.imba create mode 100644 src/router.imba diff --git a/src/helpers.imba b/src/helpers.imba new file mode 100644 index 0000000..4462d19 --- /dev/null +++ b/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 +} \ No newline at end of file diff --git a/src/index.js b/src/index.js index 8d39ac3..e6824ab 100644 --- a/src/index.js +++ b/src/index.js @@ -1,2 +1 @@ -import "pro-router/standalone" import "./main.imba" \ No newline at end of file diff --git a/src/main.imba b/src/main.imba index 60769fe..ae791f7 100644 --- a/src/main.imba +++ b/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 -

'Imba2 on Pro Router is working...' - -tag view-not_found -

"Page not found :(" +import './router.imba' tag App diff --git a/src/router.imba b/src/router.imba new file mode 100644 index 0000000..07dd1b6 --- /dev/null +++ b/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 +

'Imba2 on Pro Router is working...' + +tag view-not_found +

"Page not found :("