From 0d3e7c87bf74948f83ce006a1d340b0f3f5e68b0 Mon Sep 17 00:00:00 2001 From: Robert Jaros Date: Mon, 8 Oct 2018 13:40:04 +0200 Subject: Refactoring to modules --- kvision-modules/kvision-handlebars/build.gradle | 10 ++++++ .../kvision-handlebars/package.json.d/project.info | 3 ++ .../pl/treksoft/kvision/KVManagerHandlebars.kt | 41 ++++++++++++++++++++++ 3 files changed, 54 insertions(+) create mode 100644 kvision-modules/kvision-handlebars/build.gradle create mode 100644 kvision-modules/kvision-handlebars/package.json.d/project.info create mode 100644 kvision-modules/kvision-handlebars/src/main/kotlin/pl/treksoft/kvision/KVManagerHandlebars.kt (limited to 'kvision-modules/kvision-handlebars') diff --git a/kvision-modules/kvision-handlebars/build.gradle b/kvision-modules/kvision-handlebars/build.gradle new file mode 100644 index 00000000..918ed5a7 --- /dev/null +++ b/kvision-modules/kvision-handlebars/build.gradle @@ -0,0 +1,10 @@ +apply from: "../shared.gradle" + +kotlinFrontend { + + npm { + dependency("handlebars", "4.0.11") + dependency("handlebars-loader", "1.7.0") + } + +} diff --git a/kvision-modules/kvision-handlebars/package.json.d/project.info b/kvision-modules/kvision-handlebars/package.json.d/project.info new file mode 100644 index 00000000..fd5bb305 --- /dev/null +++ b/kvision-modules/kvision-handlebars/package.json.d/project.info @@ -0,0 +1,3 @@ +{ + "description": "KVision Handlebars module" +} diff --git a/kvision-modules/kvision-handlebars/src/main/kotlin/pl/treksoft/kvision/KVManagerHandlebars.kt b/kvision-modules/kvision-handlebars/src/main/kotlin/pl/treksoft/kvision/KVManagerHandlebars.kt new file mode 100644 index 00000000..b7f5fbc6 --- /dev/null +++ b/kvision-modules/kvision-handlebars/src/main/kotlin/pl/treksoft/kvision/KVManagerHandlebars.kt @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2017-present Robert Jaros + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package pl.treksoft.kvision + +import org.w3c.dom.asList +import kotlin.browser.document + +internal val KVManagerHandlebarsInit = KVManagerHandlebars.init() + +/** + * Internal singleton object which initializes and configures KVision handlebars module. + */ +@Suppress("EmptyCatchBlock", "TooGenericExceptionCaught") +internal object KVManagerHandlebars { + fun init() {} + + private val handlebars = try { + require("handlebars/dist/handlebars.runtime.min.js") + } catch (e: Throwable) { + } + +} -- cgit