A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/kolloch/sbt-html-js-wrap below:

kolloch/sbt-html-js-wrap: SBT plugin to convert HTML files to JavaScript files including the HTML.

sbt-web plugin for converting HTML files to JavaScript files wrapping the HTML.

You can use this plugin in combination with sbt-uglify to combine all project JavaScript and template files to one big file.

Add the plugin to project/plugins.sbt. For example:

resolvers += "Typesafe repository" at "http://repo.typesafe.com/typesafe/releases/"

addSbtPlugin("net.eigenvalue" % "sbt-html-js-wrap" % "1.0.0")

Your project's build file also needs to enable sbt-web plugins. For example with build.sbt:

lazy val root = (project.in file(".")).enablePlugins(SbtWeb)

As with all sbt-web asset pipeline plugins you must declare their order of execution e.g.:

pipelineStages := Seq(htmlJsWrap)

By default the code generated is suitable for angular:

angular.module("templates").run(["$templateCache", function($templateCache) {
  $templateCache.put("some.html","<html><body>BODY</body></html>");
}]);

The module name can be customized by:

htmlJsAngularModule := "myModule"

The complete template can be changed like this:

htmlJsTemplate := { (quotedFileName: String, quotedHtmlContent: String) =>
      s"""
         |angular.module(${JsString(htmlJsAngularModule.value)}).run(["$$templateCache", function($$templateCache) {
         |  $$templateCache.put($quotedFileName,$quotedHtmlContent);
         |}]);
      """.stripMargin
    }

You need to import spray.json.JsString for the JSON quoting like this

import spray.json.JsString

If you generally useful templates, I like to include them as easily available alternative settings. Please send me an email/message.

Include and exclude filters can be provided. For example to only include *Template.html files:

includeFilter in htmlJsWrap := "*Template.html"

Or to exclude a vendor vendor.html file:

excludeFilter in htmlJsWrap := "vendor.html"

The default filter is to include all .html files:

includeFilter in htmlJsWrap := "*.html"

This code is licensed under the Apache 2.0 License.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4