Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/ggeorgovassilis/gwt-htmlresource

HTML resource generator
https://github.com/ggeorgovassilis/gwt-htmlresource

Last synced: 8 days ago
JSON representation

HTML resource generator

Awesome Lists containing this project

README

        

# gwthtmlresource

A HTML resource generator for GWT. License [APL 2](LICENSE)

## What

TL;DR: Works just like `TextResource` but minifies the inlined HTML.

## In detail

GWT resource bundles inline images and textual information into the generated JavaScript deployable. If you need HTML fragments (eg. because you abudantly use `HTMLPanel`s you would normally inject them with a `TextResource` such as:
```java

interface ScreenTemplates extends ClientBundle {

@Source("install-app-prompt.html")
TextResource appInstallPrompt();

...

```

The example above would pick up `install-app-prompt.html`, inline it into the generated `.nocache.js` file(s) and return the html contents when `appInstallPrompt()` is invoked.

If we substitute `TextResource` with `HtmlResource` then the example becomes:
```java

interface ScreenTemplates extends ClientBundle {

@Source("install-app-prompt.html")
HtmlResource appInstallPrompt();

...

```
but the returned HTML content will be minified.

# How to use

The artefact isn't available on maven central, so you have to add a repository:

```xml


gwt-sl-mvn-repo
https://raw.github.com/ggeorgovassilis/gwt-htmlresource/mvn-repo/

true
always

```
and then use the dependency

```xml

com.georgovassilis
gwt-htmlresource
0.0.2-SNAPSHOT

```

## Releases

For GWT prior to 2.11 use 0.0.1-SNAPSHOT

For GWT 2.11 and later use 0.0.2-SNAPSHOT

## Credits

This code is based on the TextResource and TextResourceGenerator classes of the [GWT project](http://www.gwtproject.org/)