Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Java Local Development Environments Advanced Tooling Code Generation

Brendan Whiting
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Brendan Whiting
Front End Web Development Techdegree Graduate 84,738 Points

What language is this template code?

At 4:04 in the video we see template code in a different language with lots of '#' and '$'. What is that and why do they use it?

public java.lang.String toString() {
#if ( $members.size() > 0 )
#set ( $i = 0 )
    return "$classname{" +
#foreach( $member in $members )
#if ( $i == 0 )
    "##
#else
    ", ##
#end
#if ( $member.objectArray )
#if ($java_version < 5)
$member.name=" + ($member.accessor == null ? null : java.util.Arrays.asList($member.accessor)) +
#else
$member.name=" + java.util.Arrays.toString($member.accessor) +
#end
#elseif ( $member.primitiveArray && $java_version >= 5)
$member.name=" + java.util.Arrays.toString($member.accessor) +
#elseif ( $member.string )
$member.name='" + $member.accessor + '\'' +
#else
$member.name=" + $member.accessor +
#end
#set ( $i = $i + 1 )
#end
    '}';
#else
    return "$classname{}";
#end
}

2 Answers

Alexander Nikiforov
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Alexander Nikiforov
Java Web Development Techdegree Graduate 22,175 Points

It is called Velocity Template Language. Here is link to it:

http://velocity.apache.org/

Read here for more how it is used in Intellijidea:

https://www.jetbrains.com/help/idea/2016.2/file-and-code-templates.html

Although it looks to me it is very outdated... Latest Stable release in 2010

There a lot of templating langauges, take a look:

https://en.wikipedia.org/wiki/Comparison_of_web_template_engines

The one that is used in 'Spring Basics Course' is Thymeleaf

And in 'Spark Java Course' Handlebars