htmltemplate-maven-plugin

merge html fragment files into a single javascript template file used by angularjs client

License

License

Categories

Categories

Maven Build Tools
GroupId

GroupId

com.flexdms
ArtifactId

ArtifactId

htmltemplate-maven-plugin
Last Version

Last Version

0.1.0
Release Date

Release Date

Type

Type

maven-plugin
Description

Description

htmltemplate-maven-plugin
merge html fragment files into a single javascript template file used by angularjs client
Project URL

Project URL

https://github.com/jasonzhang2022/htmltemplate-maven-plugin
Project Organization

Project Organization

flexdms
Source Code Management

Source Code Management

https://github.com/jasonzhang2022/htmltemplate-maven-plugin

Download htmltemplate-maven-plugin

How to add to project

<plugin>
    <groupId>com.flexdms</groupId>
    <artifactId>htmltemplate-maven-plugin</artifactId>
    <version>0.1.0</version>
</plugin>

Dependencies

compile (5)

Group / Artifact Type Version
org.apache.maven : maven-plugin-api jar 3.1.1
org.sonatype.plexus : plexus-build-api jar 0.0.7
org.codehaus.plexus : plexus-utils jar 3.0.8
commons-io : commons-io jar 2.4
org.apache.maven.plugin-testing : maven-plugin-testing-harness jar 2.0

provided (1)

Group / Artifact Type Version
org.apache.maven.plugin-tools : maven-plugin-annotations jar 3.2

test (4)

Group / Artifact Type Version
org.apache.maven : maven-compat jar 3.0.5
junit : junit jar 4.8.2
org.apache.maven.plugins : maven-plugin-plugin jar 3.2
org.apache.maven : maven-core jar 3.1.1

Project Modules

There are no modules declared in this project.

Table of Contents

Description

maven plugin to wrap html fragments into a javascript template used by angular js client

Introduction

You often have many small html files if angular js is used. Minimization exists for js/css. We also need such tool for htmls. This is particular useful if your html templates are used in UI library. One such example is UI Bootstrap. For exmaple, bootstrap UI has many small fragments as template. The final distribution is a single javascript file with all these htmls. This plugin consolidates html files into angular js template. It is built into maven compile phase.

Usage

Add this fragement to your pom

<build>
		<plugins>
			<plugin>
				<groupId>org.apache.maven.plugins</groupid>
				<artifactId>maven-compiler-plugin</artifactid>
			</plugin>
			<plugin>
				<groupId>com.flexdms</groupid>
				<artifactId>htmltemplate-maven-plugin</artifactid>
				<version>1.0.2-SNAPSHOT</version>
				<configuration>
					<srcDirectory>src/main/webapp/fragments</srcdirectory>
					<finalFile>src/main/webapp/js/prop.js</finalfile>
				</configuration>
				<executions>
					<execution>
						<goals>
							<goal>merge</goal>
						</goals>
						<phase>compile</phase>
					</execution>
				
				</executions>
			
			</plugin>
		</plugins>
</build>

Configuration

Three parameters are available.

  1. srcDirectory: source directory. File are searched recursively. All Files found are processed.
  2. finalFile: where to output Javascript file.
  3. templateFile: optional. If omitted, internal template is used.
  4. fileHeader: header string in the final file.
  5. fileFooter: footer string in the final file
  6. generateModule: whether to generate module statement.
  7. process: whether to escape html to make it appear as valid json string. Default true. If false, text is copied without ang modification.

Example

Please run mvn test to see an example. Test set up is under src/test/resources/unit directory. Final file is writtern to target/final.js or target/final2.js

License

apache 2

Versions

Version
0.1.0