playframework / playframework/twirl
Consider indentation and remove newlines generated for "empty" lines
Nobody has claimed this yet.
- Dominant language
- Scala
- Stars
- 561
- Forks
- 118
- Avg merge
- 1d 15h
- Merged PRs (30d)
- 29
Description
Given this template:
@(list: List[String])
<html>
<body>
@if(list.isEmpty) {
<h1>Nothing to display</h1>
} else {
<h1>@list.size items!</h1>
}
</body>
</html>
The generated html will be:
<html>
<body>
<h1>2 items!</h1>
</body>
</html>
Notice that the h1 tag has an extra indentation level and it is surrounded by empty lines. This is happening because of the @if. Twirl could be smarter (and way more awesome) if it would remove a level of indentation from the branches of the if.
It could also remove the generated empty lines from the if. Please note that if the if was declared like this:
@if(list.isEmpty) { <h1>Nothing to display</h1> } else { <h1>@list.size items!</h1> } no newlines are created.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
The issue does not name implementation files or tests. Reproduce the provided Twirl template and inspect the generated HTML, then trace the template-processing entry point to determine how conditional branches produce indentation and blank lines. Done means branch content is correctly indented and empty lines from the conditional are removed without changing inline conditionals.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- scala
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100