Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kolloch/sbt-html-js-wrap
SBT plugin to convert HTML files to JavaScript files including the HTML.
https://github.com/kolloch/sbt-html-js-wrap
Last synced: 7 days ago
JSON representation
SBT plugin to convert HTML files to JavaScript files including the HTML.
- Host: GitHub
- URL: https://github.com/kolloch/sbt-html-js-wrap
- Owner: kolloch
- Created: 2014-10-04T13:24:40.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2014-10-04T15:10:33.000Z (over 10 years ago)
- Last Synced: 2025-01-11T13:55:15.284Z (11 days ago)
- Language: Scala
- Size: 133 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- awesome-sbt-plugins - sbt-html-js-wrap
README
sbt-html-js-wrap
================[sbt-web](https://github.com/sbt/sbt-web) plugin for converting HTML files to JavaScript files wrapping the HTML.
You can use this plugin in combination with [sbt-uglify](https://github.com/sbt/sbt-uglify) to combine all project
JavaScript and template files to one big file.[![Build Status](https://travis-ci.org/kolloch/sbt-html-js-wrap.png?branch=master)](https://travis-ci.org/kolloch/sbt-html-js-wrap)
Add plugin
----------Add the plugin to `project/plugins.sbt`. For example:
```scala
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.:
```scala
pipelineStages := Seq(htmlJsWrap)
```Configuration
-------------### Template
By default the code generated is suitable for angular:
```javascript
angular.module("templates").run(["$templateCache", function($templateCache) {
$templateCache.put("some.html","BODY");
}]);
```The module name can be customized by:
```scala
htmlJsAngularModule := "myModule"
```The complete template can be changed like this:
```scala
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
```scala
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.### Filters
Include and exclude filters can be provided. For example to only include *Template.html files:
```scala
includeFilter in htmlJsWrap := "*Template.html"
```Or to exclude a vendor `vendor.html` file:
```scala
excludeFilter in htmlJsWrap := "vendor.html"
```The default filter is to include all `.html` files:
```scala
includeFilter in htmlJsWrap := "*.html"
```License
-------This code is licensed under the [Apache 2.0 License][apache].
[sbt-web]: https://github.com/sbt/sbt-web
[apache]: http://www.apache.org/licenses/LICENSE-2.0.html