Discussion: Use of template engine over custom solution

Open
#103 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
25/100
Issue type
Feature
Clarity
Needs clarification
Activity status
Stale
Tech stack
java
Domain
tooling

Research direction

Start by reviewing the generator's existing template implementation and the ClassDescription model mentioned in the discussion. Compare the proposed FreeMarker, jtwig, and Thymeleaf approaches against the need for custom assertion logic; done means reaching an agreed direction and defining the migration scope.

Written by the indexing model from the issue text.

Description

This is not an issue, but a discussion as I've run into a bit of a road-block in my work.

Currently, the generator is configurable via changing the template values as shown here. The problem I'm having is that I want to add logic into these templates to, for example, generate a new assertion that is only relevant to my classes. If I want to do this, I have to write my own parser logic and call the required templates -- rather than just loading new templates.

I think one of the simplest ways to allow more flexibility is to remove the template engine from the generator and focus on using an existing engine with predefined templates. I believe the primary value of the generator is generating the model of assertions (e.g. ClassDescription) and their associating naming conventions to allow for generating these assertions. We can use this model within another engine to generate assertions

  • Apache FreeMarker - tried and true, works easily and is well known. Many features available. Additionally, uses a similar syntax for the "base" templates that we have already (${variable}).
  • jtwig - Neat new engine I've not heard of, but looks incredibly nice. Similar feature set
  • Thymeleaf - widely used, but I don't think it's well suited to work outside its domain of web generation

Looking for some input in this as I'm unsure if there were previously decisions made or after the fork it was just kept up as legacy. :)

Dominant language
Java
Stars
72
Forks
47
PR merge metrics
No merged PRs in 30d

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from assertj/assertj-generator

All issues in assertj/assertj-generator

Similar issues

More Java issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.