Skip to content

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

License

Notifications You must be signed in to change notification settings

jasonzhang2022/htmltemplate-maven-plugin

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

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

Resources

License

Stars

Watchers

Forks

Packages

No packages published