io.github.guitaro:erb-templating-maven-plugin

ERB Templating Maven Plugin

License

License

Categories

Categories

Maven Build Tools GUI User Interface
GroupId

GroupId

io.github.guitaro
ArtifactId

ArtifactId

erb-templating-maven-plugin
Last Version

Last Version

1.0
Release Date

Release Date

Type

Type

maven-plugin
Description

Description

io.github.guitaro:erb-templating-maven-plugin
ERB Templating Maven Plugin
Project URL

Project URL

https://github.com/guitaro/erb-templating-maven-plugin
Source Code Management

Source Code Management

https://github.com/guitaro/erb-templating-maven-plugin.git

Download erb-templating-maven-plugin

How to add to project

<plugin>
    <groupId>io.github.guitaro</groupId>
    <artifactId>erb-templating-maven-plugin</artifactId>
    <version>1.0</version>
</plugin>

Dependencies

compile (4)

Group / Artifact Type Version
org.apache.maven : maven-plugin-api jar 3.2.5
org.jruby : jruby-complete jar 1.7.19
org.apache.maven : maven-project jar 3.0-alpha-2
org.apache.maven.shared : maven-filtering jar 1.3

provided (1)

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

test (1)

Group / Artifact Type Version
junit : junit jar 4.12

Project Modules

There are no modules declared in this project.

erb-templating-maven-plugin

Maven plugin which parse ERB file templates with YAML variables contexts.

Syntax

Let's take for example this context :

name: "world!"
var2:
    attribute: 123
shopping_list:
 - potatoes
 - tomatoes
 - eggs

Variables

<%# This is just a comment %>
Hello, <%= @name %>.
Today is <%= Time.now.strftime('%A') %>.

Structure controle

If/else

<%= if @var1 == "someText" %>
    I'm in if
<% else %>
    I'm in else
<% end %>

For

<% for @item in @shopping_list %>
  <%= @item %>
<% end %>

Foreach (array)

<%= if @array.each do |value| %>
    <%= @value %>
<% end %>

Foreach (map)

Iterate through key/value pair :

<%= if @map.each do |key, value| %>
    <%= @key %> => <%= @value %>
<% end %>

Iterate through keys :

<%= if @map.each_key do |key| %>
    <%= @key %> => <%= @map[@key] %>
<% end %>

Iterate through values :

<%= if @map.each_value do |value| %>
    <%= @value %>
<% end %>

How to use

Add maven plugin dependency :

<build>
    <plugins>
        <plugin>
            <groupId>io.levyndot</groupId>
            <artifactId>erb-templating-maven-plugin</artifactId>
            <version>1.0</version>
            ...
        </plugin>
    </plugins>
</build>

Configure execution :

<executions>
    <execution>
        <id>templating</id>
        <goals>
            <goal>run</goal>
        </goals>
        <configuration>
            <templates>
                <template>${project.basedir}/templates/**/*</template>
                <template>${project.basedir}/other_templates/template.txt.erb</template>
            </templates>
            <contexts>
                <context>${project.basedir}/contexts/**/*</context>
                <context>${project.basedir}/other_context/vars.yaml</context>
            </contexts>
            <targetDir>${project.build.directory}</targetDir>
            <removeExtension>true</removeExtension>
            <skip>false</skip>
        </configuration>
    </execution>
</executions>

Options :

name type Default Description
templates List empty list List of ERB templates files. Can be a wildcard on the end of path. Middle wildcards are not supported.
contexts List empty list List of YAML variables files. Can be a wildcard on the end of path. Middle wildcards are not supported.
targetDir String ${project.build.directory} Path to output files.
removeExtension Boolean false If true, so output file will be renamed without ".erb" extension.
skip Boolean false If true, the plugin will not be run.

Versions

Version
1.0